apache Ansible行动手册-任务在执行时卡住

rseugnpd  于 2023-03-03  发布在  Apache
关注(0)|答案(1)|浏览(539)

我目前正在学习Ansible,尝试自动化安装和配置Web服务器等操作。我的问题是使用Ansible Apache 2模块运行命令“a2 dismod deflate”的任务在执行时卡住了。
以下是完整的行动手册:

- name: Install apache2
  apt: name=apache2 update_cache=yes state=latest

- name: Ensure apache2 is running
  service:
          name: apache2
          state: started
          enabled: true
  
- name: Enable modules needed for redirection and SSL
  apache2_module:
          state: present
          name: "{{ item }}"
  with_items:
     - rewrite
     - headers
     - proxy
     - proxy_http
     - ssl
     - cache
 
- name: Disable module
  apache2_module:
          state: absent
          name: "{{ item }}"
  with_items:
     - deflate
 
- name: Configure apache2 - AllowOverride None to AllowOverride All
 
  lineinfile:
          path: /etc/apache2/apache2.conf
          regexp: '^(\s*)AllowOverride\s+None(\s*)$'
          line: '\1AllowOverride All\2'
          backrefs: yes
          state: present
          insertafter: '^<Directory /var/www>'
          insertbefore: '^</Directory>'
  
- name: Restart apache2
  service:
          name: apache2
          state: restarted

我尝试在目标服务器上 checkout 进程,似乎命令已成功执行,但在运行此特定命令后,进程被卡住:“/usr/bin/htcacheclean -d 120 -p /var/缓存/apache 2/mod缓存磁盘-l 300 M-n

root       41728  0.0  0.0   2888   988 pts/1    Ss+  10:21   0:00      \_ /bin/sh -c /usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1676974885.4424312-24196163579435/AnsiballZ_
root       41729  0.0  2.4  35024 24104 pts/1    S+   10:21   0:00          \_ /usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1676974885.4424312-24196163579435/AnsiballZ_apache2
root       41733  0.0  0.8  14252  8796 pts/1    S+   10:21   0:00              \_ /usr/bin/perl -w /usr/sbin/a2dismod deflate
root        1253  0.0  0.8 295540  8756 ?        Ssl  09:24   0:00 /usr/libexec/packagekitd
root       13942  0.0  0.5  11532  5644 ?        Ss   09:27   0:00 /lib/systemd/systemd-udevd
systemd+   14243  0.0  0.5  16120  5712 ?        Ss   09:27   0:00 /lib/systemd/systemd-networkd
systemd+   14249  0.0  0.8  25260  8884 ?        Ss   09:27   0:00 /lib/systemd/systemd-resolved
root       14251  0.0  1.1  31320 11036 ?        S<s  09:27   0:00 /lib/systemd/systemd-journald
systemd+   14322  0.0  0.4  89356  4956 ?        Ssl  09:27   0:00 /lib/systemd/systemd-timesyncd
root       25995  0.1  2.4 735960 24048 ?        Ssl  09:28   0:04 /usr/lib/snapd/snapd
root       39584  0.0  0.4   6768  4480 ?        Ss   09:29   0:00 /usr/sbin/apache2 -k start
www-data   39586  0.0  0.4 752984  4380 ?        Sl   09:29   0:00  \_ /usr/sbin/apache2 -k start
www-data   39587  0.0  0.4 752984  4380 ?        Sl   09:29   0:00  \_ /usr/sbin/apache2 -k start
www-data   39707  0.0  0.0   3736   160 ?        Ss   09:29   0:00 /usr/bin/htcacheclean -d 120 -p /var/cache/apache2/mod_cache_disk -l 300M -n
root       40930  0.0  0.9  17088  9360 ?        Ss   10:19   0:00 /lib/systemd/systemd --user
root       40931  0.0  0.4 170712  4360 ?        S    10:19   0:00  \_ (sd-pam)
pkln4tw6

pkln4tw61#

解决办法是增加“力:true”,行动手册卡住的原因是,如果您执行a2dismod命令,则会出现警告提示。

相关问题