我无法使用ansible composer模块运行symfony flex命令composer dump-env prod
。我想知道它是否可能?我的任务看起来像这样:
- name: Composer dump env for production
composer:
command: dump-env
working_dir: "{{ app_composer_package_dir }}"
arguments: prod
become_user: "{{app_apache_user}}"
become: yes
我得到的错误是:
"stderr": "\
n [Symfony\Component\Console\Exception\CommandNotFoundException] 没有定义 \"dump-env" 的命令。
Ansible 详细日志:
fatal: [testhost.com]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"apcu_autoloader": false,
"arguments": "prod",
"classmap_authoritative": false,
"command": "dump-env",
"executable": null,
"global_command": false,
"ignore_platform_reqs": false,
"no_dev": true,
"no_plugins": false,
"no_scripts": false,
"optimize_autoloader": true,
"prefer_dist": false,
"prefer_source": false,
"working_dir": "/var/www/source"
}
},
"msg": "[Symfony\Component\Console\Exception\CommandNotFoundException] Command "dump-env" is not defined. help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]"
}
",
我尝试了 ansiblecommand
模块直接运行该命令,但出现相同的错误。
但是,我可以通过 sshing 到远程 (centos) 实例来运行该命令:
sudo -u apache composer dump-env prod
将"symfony/symfony"中列出的软件包限制为"4.3.*">
已成功转储 .env.local 中的 .env 文件.php
到目前为止,我无法使用ansible作曲家模块运行composer dump-env prod
命令。但是,使用ansible命令模块成功运行以下任务,例如
- name: Composer dump env for production
command: "{{composer_install_path}} --working-dir={{ app_composer_package_dir }} dump-env prod"
become_user: "{{app_apache_user}}"
become: yes
翻译为 sth:
sudo -u apache /usr/local/bin/composer --working-dir=/var/www/source dump-env prod