Ansible 任务没有安装正确的包
Ansible task not installing the right package
我在我的 Ansible 任务中指定 php70u
。但是,ph71u
似乎被安装了。我想弄清楚为什么。
Ansible 版本:
me@virtualbox:~/Desktop/ansible_centos$ ansible --version
ansible 2.5.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/me/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
确认当前没有安装 PHP 个软件包:
[me@server ~]$ rpm -qa | grep php
[me@server ~]$
正在确认 IUS 存储库已安装:
[me@server ~]$ sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.its.sfu.ca
* epel: mirrors.mit.edu
* extras: mirror.gpmidi.net
* ius: ftp.rediris.es
* updates: mirror.it.ubc.ca
repo id repo name
base CentOS-6 - Base
epel Extra Packages for Enterprise Linux 6 - x86_64
extras
CentOS-6 - Extras
ius IUS Community Packages for Enterprise Linux 6 - x86_64
updates CentOS-6 - Updates
repolist: 20,549
Ansible 任务
- name: install PHP7
yum: name=php70u state=present
Ansible 错误:
TASK [php : install PHP7] ******************************************************
fatal: [local_centos6_vm]: FAILED! => {"changed": false, "msg": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64\n", "rc": 1, "results": ["Loaded plugins: fastestmirror\nSetting up Install Process\nLoading mirror speeds from cached hostfile\n * base: mirror.its.sfu.ca\n * epel: download-ib01.fedoraproject.org\n * extras: mirror.gpmidi.net\n * ius: mirror.slu.cz\n * updates: mirror.it.ubc.ca\nResolving Dependencies\n--> Running transaction check\n---> Package mod_php70u.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Dependency: php-common(x86-64) = 7.0.27-1.ius.centos6 for package: mod_php70u-7.0.27-1.ius.centos6.x86_64\n--> Running transaction check\n---> Package php70u-common.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php-common < 7.1.14-1.ius.centos6\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php70u-common\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
然后,如果我尝试查看安装了哪些 PHP 软件包,我会得到:
[me@server ~]$ rpm -qa | grep php
php71u-common-7.1.14-1.ius.centos6.x86_64
php71u-cli-7.1.14-1.ius.centos6.x86_64
php71u-xml-7.1.14-1.ius.centos6.x86_64
php71u-process-7.1.14-1.ius.centos6.x86_64
如果我删除所有 php71u*
个软件包,我可以手动重新安装:
sudo yum install php70u
[me@server~]$ rpm -qa | grep php
php70u-common-7.0.27-1.ius.centos6.x86_64
mod_php70u-7.0.27-1.ius.centos6.x86_64
[me@server ~]$
编辑#1
使用 command 模块代替 yum 模块:
- name: install PHP7
command: yum install php70u
结果:
TASK [php : install PHP7] ******************************************************
[WARNING]: Consider using yum module rather than running yum
fatal: [local_centos6_vm]: FAILED! => {"changed": true, "cmd": ["yum", "install", "php70u"], "delta": "0:00:02.861760", "end": "2018-02-27 14:22:45.971565", "msg": "non-zero return code", "rc": 1, "start": "2018-02-27 14:22:43.109805", "stderr": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64", "stderr_lines": ["Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64"],
编辑#2
我决定添加任务删除PHP71u
- name: remove PHP71u
yum: name=php71u state=absent
- name: install PHP70u
yum: name=php70u state=present
我遇到了同样的问题:
TASK [php : remove PHP71u] *****************************************************
ok: [local_centos6_vm]
TASK [php : install PHP70u] ****************************************************
fatal: [local_centos6_vm]: FAILED! => {"changed": false, "msg": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64\n", "rc": 1, "results": ["Loaded plugins: fastestmirror\nSetting up Install Process\nLoading mirror speeds from cached hostfile\n * base: mirror.its.sfu.ca\n * epel: mirrors.lug.mtu.edu\n * extras: mirror.gpmidi.net\n * ius: mirror.slu.cz\n * updates: mirror.it.ubc.ca\nResolving Dependencies\n--> Running transaction check\n---> Package mod_php70u.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Dependency: php-common(x86-64) = 7.0.27-1.ius.centos6 for package: mod_php70u-7.0.27-1.ius.centos6.x86_64\n--> Running transaction check\n---> Package php70u-common.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php-common < 7.1.14-1.ius.centos6\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php70u-common\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
编辑#3
找到脚本后,我 运行 它带有生成 debug_dir
的 explode 参数。然后,我搜索 php
并找到一行 php70u
:
[me@server debug_dir]$ grep -ir ".*php.*"
args:{"ANSIBLE_MODULE_ARGS": {"_ansible_version": "2.5.0", "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "name": "php70u", "_ansible_module_name": "yum", "_ansible_verbosity": 3, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "state": "present", "_ansible_diff": false, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "_ansible_no_log": false}}
这是删除 PHP71u 的内容调试文件:
[me@server debug_dir]$ grep -ir php
args:{"ANSIBLE_MODULE_ARGS": {"_ansible_version": "2.5.0", "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "name": "php71u", "_ansible_module_name": "yum", "_ansible_verbosity": 3, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "state": "absent", "_ansible_diff": false, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "_ansible_no_log": false}}
RPM 抛出的错误消息:
Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64
...意味着 php71u
是 已经以某种方式安装了。
直到你找到根本原因,因为你不希望它在安装之前放置一个任务来删除它:
- name: remove php71u
yum: name=php71u state=absent
我的错。我正在单独安装 pear,这是另一个任务的一部分,在一个公共项目列表中。这是在我安装 php70u
.
之前安装 php71u
我在注释掉我的 php 角色、手动安装 php70u 并遇到我的常用项目列表问题后发现了这一点。
我在我的 Ansible 任务中指定 php70u
。但是,ph71u
似乎被安装了。我想弄清楚为什么。
Ansible 版本:
me@virtualbox:~/Desktop/ansible_centos$ ansible --version
ansible 2.5.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/me/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
确认当前没有安装 PHP 个软件包:
[me@server ~]$ rpm -qa | grep php
[me@server ~]$
正在确认 IUS 存储库已安装:
[me@server ~]$ sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.its.sfu.ca
* epel: mirrors.mit.edu
* extras: mirror.gpmidi.net
* ius: ftp.rediris.es
* updates: mirror.it.ubc.ca
repo id repo name
base CentOS-6 - Base
epel Extra Packages for Enterprise Linux 6 - x86_64
extras
CentOS-6 - Extras
ius IUS Community Packages for Enterprise Linux 6 - x86_64
updates CentOS-6 - Updates
repolist: 20,549
Ansible 任务
- name: install PHP7
yum: name=php70u state=present
Ansible 错误:
TASK [php : install PHP7] ******************************************************
fatal: [local_centos6_vm]: FAILED! => {"changed": false, "msg": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64\n", "rc": 1, "results": ["Loaded plugins: fastestmirror\nSetting up Install Process\nLoading mirror speeds from cached hostfile\n * base: mirror.its.sfu.ca\n * epel: download-ib01.fedoraproject.org\n * extras: mirror.gpmidi.net\n * ius: mirror.slu.cz\n * updates: mirror.it.ubc.ca\nResolving Dependencies\n--> Running transaction check\n---> Package mod_php70u.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Dependency: php-common(x86-64) = 7.0.27-1.ius.centos6 for package: mod_php70u-7.0.27-1.ius.centos6.x86_64\n--> Running transaction check\n---> Package php70u-common.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php-common < 7.1.14-1.ius.centos6\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php70u-common\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
然后,如果我尝试查看安装了哪些 PHP 软件包,我会得到:
[me@server ~]$ rpm -qa | grep php
php71u-common-7.1.14-1.ius.centos6.x86_64
php71u-cli-7.1.14-1.ius.centos6.x86_64
php71u-xml-7.1.14-1.ius.centos6.x86_64
php71u-process-7.1.14-1.ius.centos6.x86_64
如果我删除所有 php71u*
个软件包,我可以手动重新安装:
sudo yum install php70u
[me@server~]$ rpm -qa | grep php
php70u-common-7.0.27-1.ius.centos6.x86_64
mod_php70u-7.0.27-1.ius.centos6.x86_64
[me@server ~]$
编辑#1
使用 command 模块代替 yum 模块:
- name: install PHP7
command: yum install php70u
结果:
TASK [php : install PHP7] ******************************************************
[WARNING]: Consider using yum module rather than running yum
fatal: [local_centos6_vm]: FAILED! => {"changed": true, "cmd": ["yum", "install", "php70u"], "delta": "0:00:02.861760", "end": "2018-02-27 14:22:45.971565", "msg": "non-zero return code", "rc": 1, "start": "2018-02-27 14:22:43.109805", "stderr": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64", "stderr_lines": ["Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64"],
编辑#2
我决定添加任务删除PHP71u
- name: remove PHP71u
yum: name=php71u state=absent
- name: install PHP70u
yum: name=php70u state=present
我遇到了同样的问题:
TASK [php : remove PHP71u] *****************************************************
ok: [local_centos6_vm]
TASK [php : install PHP70u] ****************************************************
fatal: [local_centos6_vm]: FAILED! => {"changed": false, "msg": "Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64\n", "rc": 1, "results": ["Loaded plugins: fastestmirror\nSetting up Install Process\nLoading mirror speeds from cached hostfile\n * base: mirror.its.sfu.ca\n * epel: mirrors.lug.mtu.edu\n * extras: mirror.gpmidi.net\n * ius: mirror.slu.cz\n * updates: mirror.it.ubc.ca\nResolving Dependencies\n--> Running transaction check\n---> Package mod_php70u.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Dependency: php-common(x86-64) = 7.0.27-1.ius.centos6 for package: mod_php70u-7.0.27-1.ius.centos6.x86_64\n--> Running transaction check\n---> Package php70u-common.x86_64 0:7.0.27-1.ius.centos6 will be installed\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php-common < 7.1.14-1.ius.centos6\n--> Processing Conflict: php71u-common-7.1.14-1.ius.centos6.x86_64 conflicts php70u-common\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
编辑#3
找到脚本后,我 运行 它带有生成 debug_dir
的 explode 参数。然后,我搜索 php
并找到一行 php70u
:
[me@server debug_dir]$ grep -ir ".*php.*"
args:{"ANSIBLE_MODULE_ARGS": {"_ansible_version": "2.5.0", "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "name": "php70u", "_ansible_module_name": "yum", "_ansible_verbosity": 3, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "state": "present", "_ansible_diff": false, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "_ansible_no_log": false}}
这是删除 PHP71u 的内容调试文件:
[me@server debug_dir]$ grep -ir php
args:{"ANSIBLE_MODULE_ARGS": {"_ansible_version": "2.5.0", "_ansible_selinux_special_fs": ["fuse", "nfs", "vboxsf", "ramfs", "9p"], "name": "php71u", "_ansible_module_name": "yum", "_ansible_verbosity": 3, "_ansible_syslog_facility": "LOG_USER", "_ansible_socket": null, "state": "absent", "_ansible_diff": false, "_ansible_debug": false, "_ansible_shell_executable": "/bin/sh", "_ansible_check_mode": false, "_ansible_no_log": false}}
RPM 抛出的错误消息:
Error: php71u-common conflicts with php70u-common-7.0.27-1.ius.centos6.x86_64
...意味着 php71u
是 已经以某种方式安装了。
直到你找到根本原因,因为你不希望它在安装之前放置一个任务来删除它:
- name: remove php71u
yum: name=php71u state=absent
我的错。我正在单独安装 pear,这是另一个任务的一部分,在一个公共项目列表中。这是在我安装 php70u
.
php71u
我在注释掉我的 php 角色、手动安装 php70u 并遇到我的常用项目列表问题后发现了这一点。