geerlingguy / ansible-role-repo-epel

Ansible Role - EPEL Repository for RHEL/CentOS
https://galaxy.ansible.com/geerlingguy/repo-epel/
MIT License
186 stars 148 forks source link

Fix #23 #25

Closed trinitronx closed 6 years ago

trinitronx commented 6 years ago

The role appeared to fail in a non-idempotent way due to task "failed": true being set, even when yum package was already installed and it should just continue.

Looks like checking return code != 0 is better in this case, as it's correctly set to 0 when yum says it's already installed.

Error was:

  TASK [geerlingguy.repo-epel : Install EPEL repo.] ******************************
  task path: /tmp/kitchen/roles/geerlingguy.repo-epel/tasks/main.yml:6
  FAILED - RETRYING: Install EPEL repo. (5 retries left).
  FAILED - RETRYING: Install EPEL repo. (4 retries left).
  FAILED - RETRYING: Install EPEL repo. (3 retries left).
  FAILED - RETRYING: Install EPEL repo. (2 retries left).
  FAILED - RETRYING: Install EPEL repo. (1 retries left).
  fatal: [localhost]: FAILED! => {"attempts": 5, "changed": false, "failed": true, "msg": "", "rc": 0, "results": ["epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarch9yXbfu.rpm is already installed"]}
  to retry, use: --limit @/tmp/kitchen/default.retry

  PLAY RECAP *********************************************************************
  localhost                  : ok=2    changed=0    unreachable=0    failed=1
shhirose commented 6 years ago

This phenomenon appears to be caused by the environment. It occurred on my machine. However, it did not occur on another machine.

As long as I see the log, I think that it would be incorrect to become an failed. However, I do not know the cause.

Write the log executed with -vvv.

epel-release is not installed.

[vagrant@localhost ~]$ sudo yum info epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
Available Packages
Name        : epel-release
Arch        : noarch
Version     : 7
Release     : 9
Size        : 14 k
Repo        : extras/7/x86_64
Summary     : Extra Packages for Enterprise Linux repository configuration
URL         : http://download.fedoraproject.org/pub/epel
License     : GPLv2
Description : This package contains the Extra Packages for Enterprise Linux (EPEL) repository
            : GPG key as well as configuration for yum.

Playbook log.

[vagrant@localhost ansible]$ ansible-playbook -i inventory/dev release.yml -c local -vvv
ansible-playbook 2.5.0
  config file = /ansible/ansible.cfg
  configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /ansible/ansible.cfg as config file
Parsed /ansible/inventory/dev inventory source with ini plugin

PLAYBOOK: release.yml **************************************************************************************************************************************************************
1 plays in release.yml

PLAY [server] *************************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************
task path: /ansible/release.yml:2
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683 `" && echo ansible-tmp-1521940427.52-137634787537683="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmpAY6ZcX TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683/setup.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683/setup.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-faoejjetzqtddlnuxgjzeypzxybpksuz; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683/setup.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940427.52-137634787537683/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [geerlingguy.repo-epel : Check if EPEL repo is already configured.] ***********************************************************************************************************
task path: /ansible/roles/geerlingguy.repo-epel/tasks/main.yml:2
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/stat.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745 `" && echo ansible-tmp-1521940428.28-144116661600745="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmpB7nUNZ TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745/stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745/stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-leustbriqoeoztnfmcdjwyemlncdrzuc; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745/stat.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.28-144116661600745/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "checksum_algorithm": "sha1",
            "follow": false,
            "get_attributes": true,
            "get_checksum": true,
            "get_md5": null,
            "get_mime": true,
            "path": "/etc/yum.repos.d/epel.repo"
        }
    },
    "stat": {
        "exists": false
    }
}

TASK [geerlingguy.repo-epel : Install EPEL repo.] **********************************************************************************************************************************
task path: /ansible/roles/geerlingguy.repo-epel/tasks/main.yml:6
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122 `" && echo ansible-tmp-1521940428.74-72916870384122="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmplZzPay TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-kxzssihbwebnitmsonrciqieyoubebgh; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940428.74-72916870384122/ > /dev/null 2>&1 && sleep 0'
FAILED - RETRYING: Install EPEL repo. (5 retries left).Result was: {
    "attempts": 1,
    "changed": true,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "Loaded plugins: fastestmirror\nExamining /tmp/epel-release-latest-7.noarchugD_q5.rpm: epel-release-7-11.noarch\nMarking /tmp/epel-release-latest-7.noarchugD_q5.rpm to be installed\nResolving Dependencies\n--> Running transaction check\n---> Package epel-release.noarch 0:7-11 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package         Arch      Version Repository                              Size\n================================================================================\nInstalling:\n epel-release    noarch    7-11    /epel-release-latest-7.noarchugD_q5     24 k\n\nTransaction Summary\n================================================================================\nInstall  1 Package\n\nTotal size: 24 k\nInstalled size: 24 k\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n  Installing : epel-release-7-11.noarch                                     1/1 \n  Verifying  : epel-release-7-11.noarch                                     1/1 \n\nInstalled:\n  epel-release.noarch 0:7-11                                                    \n\nComplete!\n"
    ],
    "retries": 6
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734 `" && echo ansible-tmp-1521940443.36-107022500003734="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmp8m1w7M TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ypigpmpcudsuekejbjtsmaklmoshxmrz; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940443.36-107022500003734/ > /dev/null 2>&1 && sleep 0'
FAILED - RETRYING: Install EPEL repo. (4 retries left).Result was: {
    "attempts": 2,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarch4s0HTv.rpm is already installed"
    ],
    "retries": 6
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209 `" && echo ansible-tmp-1521940455.29-139647722711209="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmpURt3T7 TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-kfqmexmhruhptyyyoyzshxwyyyfqdlbz; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940455.29-139647722711209/ > /dev/null 2>&1 && sleep 0'
FAILED - RETRYING: Install EPEL repo. (3 retries left).Result was: {
    "attempts": 3,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarch7qzIVW.rpm is already installed"
    ],
    "retries": 6
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313 `" && echo ansible-tmp-1521940467.39-16287608254313="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmptDml6i TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ftthvvtbmajxyjbuhfisaniosffxdgpt; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940467.39-16287608254313/ > /dev/null 2>&1 && sleep 0'
FAILED - RETRYING: Install EPEL repo. (2 retries left).Result was: {
    "attempts": 4,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarchQV8gEZ.rpm is already installed"
    ],
    "retries": 6
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338 `" && echo ansible-tmp-1521940479.17-106716591330338="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmpCk8KUs TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-cdetuhhulickkvtrjtyepbapmkopatec; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940479.17-106716591330338/ > /dev/null 2>&1 && sleep 0'
FAILED - RETRYING: Install EPEL repo. (1 retries left).Result was: {
    "attempts": 5,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarchttb8Yv.rpm is already installed"
    ],
    "retries": 6
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/packaging/os/yum.py
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609 `" && echo ansible-tmp-1521940492.38-131310370916609="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609 `" ) && sleep 0'
<localhost> PUT /home/vagrant/.ansible/tmp/ansible-local-2374QeIGXV/tmpzGfZ12 TO /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609/yum.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609/ /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609/yum.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-qziztlmlytuyhjycilnlsjxmwejxkeeq; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609/yum.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1521940492.38-131310370916609/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "attempts": 5,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "conf_file": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": null,
            "enable_plugin": [],
            "enablerepo": null,
            "exclude": null,
            "install_repoquery": true,
            "installroot": "/",
            "list": null,
            "name": [
                "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
            ],
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "",
    "rc": 0,
    "results": [
        "epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarchyaNzKm.rpm is already installed"
    ]
}
        to retry, use: --limit @/ansible/release.retry

PLAY RECAP *************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1
perryk commented 6 years ago

I also have this issue after upgrading to Ansible 2.5 when using this role to install epel and receive a similar message to:

"epel-release-7-11.noarch providing /tmp/epel-release-latest-7.noarch7qzIVW.rpm is already installed"

I'm using Vagrant to build VMs with geerlingguy/centos7 as the box/base.

If I re-rerun provisioning, everything is ok on the second attempt.

kylegoch commented 6 years ago

Seeing this as well with Ansible 2.5.0, however downgrading to 2.4.4 caused it to work again.

geerlingguy commented 6 years ago

D'oh! Thanks for the PR, checking it over and will merge in a few.