与成为和chdir的Ansible命令

时间:2018-12-31 14:36:20

标签: ansible command

我有这个:

- name: composer install in includes
      become: yes
      become_user: git
      become_method: sudo
      become_flags: '-s'
      chdir: /var/www/html/includes
      command: php /usr/local/bin/composer install
      creates: /var/www/html/includes/vendor

运行它时,出现错误“ Composer在/ home / git中找不到composer.json文件”。但是请注意,我为/ var / www / html / includes指定了一个chdir,该目录确实具有composer.json。还要注意,在尝试时,我添加了begin_method和begin_flags。 -s应该告诉sudo不要更改目录或加载环境。

有人知道我在做什么错吗?

谢谢埃德

1 个答案:

答案 0 :(得分:0)

我认为任务应该这样写:

- name: composer install in includes
      become: yes
      become_user: git
      become_method: sudo
      become_flags: '-s'
      command: php /usr/local/bin/composer install
      args:
        chdir: /var/www/html/includes
        creates: /var/www/html/includes/vendor

有关更多信息,您可以运行: $ ansible-doc command