我必须以用户apache 的身份在多个主机上运行 symfony 清除缓存,该用户在 /etc/passwd 中有/sbin/nologin作为 shell。通常我使用以下命令执行此操作:sudo su - apache -s /bin/bash -c "php /var/www/html/api.sellsecure.com/bin/console cache:clear --env=prod"
目前我的剧本是这样的:
---
- name: "test"
hosts: app-servers
gather_facts: yes
become: yes
tasks:
- name: "Clear symfony cache"
command: sudo su - apache -s /bin/bash -c "php /var/www/html/api.sellsecure.com/bin/console cache:clear --env=prod"
但是在运行过程中我收到警告:
[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather than running sudo
我尝试了几种组合,但我永远无法让它发挥作用。
我是 ansible noobie,我想了解使用 ansible 运行此任务的最佳方法。
---
- name: "test"
hosts: app-servers
gather_facts: yes
become: yes
become_user: apache
become_flags: '-s /bin/bash'
tasks:
- name: "Clear symfony cache"
command: "php /var/www/html/api.sellsecure.com/bin/console cache:clear --env=prod"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句