Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to transfer file to ~/.ansible/tmp/ansible-tmp-xxx/setup.py: [Errno 2] No such file or directory #21562

Closed
avivian opened this issue Feb 17, 2017 · 45 comments

Comments

Projects
None yet
@avivian
Copy link

commented Feb 17, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible-playbook setup

ANSIBLE VERSION
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT

Linux ip-x-x-x-x 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-1 (2016-03-06) x86_64 GNU/Linux

SUMMARY

When running ansible localhost using cloud-init, the following error is given:

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py'"}
        to retry, use: --limit @/tmp/ansible/server/deploy_rancher_master.retry

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

This works using version 2.2.0.0.

STEPS TO REPRODUCE

We run our playbooks on AWS as part of a cloud-init script used in a cloudformation template. The playbooks are downloaded on to the instance and run using:

ansible-playbook /tmp/ansible/server/deploy_rancher_master.yml --extra-vars "extra=vars"

Ansible is installed using apt:

apt-get -y -t jessie-backports install ansible

Sample cloudformation template can be provided if required.

EXPECTED RESULTS

Setup task to complete.

ACTUAL RESULTS
Error in setup task:
TASK [setup] *******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py'"}
        to retry, use: --limit @/tmp/ansible/server/deploy_rancher_master.retry

This works using version 2.2.0.0

@jctanner

This comment has been minimized.

Copy link
Member

commented Feb 17, 2017

@avivian please run ansbile-playbook with -vvvv and paste the results here.

needs_info

@BenBewickJet

This comment has been minimized.

Copy link

commented Feb 20, 2017

I've recently started having the same issue with ansible scripts called from /etc/rc.local

`Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/init.pyc

PLAYBOOK: startup.yml **********************************************************
1 plays in /etc/ansible/startup.yml

PLAY [all] *********************************************************************

TASK [gather ec2 facts] ********************************************************
task path: /etc/ansible/startup.yml:10
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/cloud/amazon/ec2_facts.py
ESTABLISH LOCAL CONNECTION FOR USER: root
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo ~/.ansible/tmp/ansible-tmp-1487627348.46-252760944418207" && echo ansible-tmp-1487627348.46-252760944418207="echo ~/.ansible/tmp/ansible-tmp-1487627348.46-252760944418207" ) && sleep 0'
PUT /tmp/tmpvmMpk_ TO ~/.ansible/tmp/ansible-tmp-1487627348.46-252760944418207/ec2_facts.py
fatal: [web]: FAILED! => {
"failed": true,
"msg": "failed to transfer file to /.ansible/tmp/ansible-tmp-1487627348.46-252760944418207/ec2_facts.py: [Errno 2] No such file or directory: '/.ansible/tmp/ansible-tmp-1487627348.46-252760944418207/ec2_facts.py'"
}`

I have discovered that it is creating the directory path as a literal ~ underneath the /etc/ansible

root@web:/etc/ansible/~/.ansible/tmp# pwd /etc/ansible/~/.ansible/tmp root@web:/etc/ansible/~/.ansible/tmp# ls -la total 16 drwx------ 4 root root 4096 Feb 21 08:49 . drwx------ 3 root root 4096 Feb 21 08:43 .. drwx------ 2 root root 4096 Feb 21 08:43 ansible-tmp-1487627033.76-180215344939948 drwx------ 2 root root 4096 Feb 21 08:49 ansible-tmp-1487627348.46-252760944418207
but then trying to use path with ~ is getting shell expansion to root home where the path does not actually exist.

Script runs correctly when run from a login session.

@pdecat

This comment has been minimized.

Copy link

commented Feb 22, 2017

Same issue here with 2.2.1 (ok with 2.2.0).

Two workarounds:

  1. set those in ansible.cfg:
remote_tmp = $HOME/.ansible/tmp
local_tmp = $HOME/.ansible/tmp
  1. pass those environment variables to ansible-local command:
ANSIBLE_LOCAL_TEMP=$HOME/.ansible/tmp
ANSIBLE_REMOTE_TEMP=$HOME/.ansible/tmp

Related to #20332 and #21339

Edit: as suggested by others, those workarounds only work when the HOME environment variable is defined, which is not the case with cloud-init. In that case, setting HOME=/root helps.

@hehnope

This comment has been minimized.

Copy link

commented Mar 11, 2017

I can confirm what @pdecat said; 2.2.1 seems to have introduced this bug. Currently, I'm just installing ansible with pip install ansible==2.2.0 to avoid this bug.

@decafdennis

This comment has been minimized.

Copy link

commented Mar 16, 2017

We're running a small playbook with local connection triggered by a Serf member join/leave event, and that stopped working with 2.2.1. It works when running from an interactive shell with 2.2.1, and it works when run from Serf with 2.2.0. My workaround is to downgrade, like @jersten.

Error:

fatal: [10.0.11.79]: FAILED! => {"changed": true, "failed": true, "msg": "Source /root/.ansible/tmp/ansible-tmp-1489689949.12-21813754930704/source not found"}
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2017

@avivian This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@ansibot ansibot added needs_info and removed needs_info labels Mar 21, 2017

@hehnope

This comment has been minimized.

Copy link

commented Mar 21, 2017

@ansibot bot_broken this bug affects multiple people.

@hehnope

This comment has been minimized.

Copy link

commented Mar 21, 2017

@jctanner

Here is the info:

TASK [xxx : xxx] ************************************
task path: /opt/xxx/ansible/playbooks/roles/common/tasks/xxx.yml:2
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt_repository.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1490134142.15-134458515671021 `" && echo ansible-tmp-1490134142.15-134458515671021="` echo ~/.ansible/tmp/ansible-tmp-1490134142.15-134458515671021 `" ) && sleep 0'
<localhost> PUT /tmp/tmpL4eBs2 TO ~/.ansible/tmp/ansible-tmp-1490134142.15-134458515671021/apt_repository.py
fatal: [localhost]: FAILED! => {
    "failed": true, 
    "msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1490134142.15-134458515671021/apt_repository.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1490134142.15-134458515671021/apt_repository.py'"
}
	to retry, use: --limit @/opt/xxx/ansible/playbooks/xxx.retry
@rschmidtz

This comment has been minimized.

Copy link

commented Apr 5, 2017

same issue here running from EC2 user_data

Ansible 2.2.1.0
Ubuntu xenial 16.04

file or directory: '~/.ansible/tmp/ansible-tmp-xxx/setup.py

@wvidana

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2017

Similar issue here running EC2 user_data

  • Ansible 2.3.0
  • Ubuntu 14.04.5 LTS

Failure on locating a template on the template folder of a role: "msg": "Source /root/.ansible/tmp/ansible-tmp-1492010526.34-162074643457251/source not found"

This problem is not present when using Ansible 2.2.0

@errriclee

This comment has been minimized.

Copy link

commented Apr 28, 2017

I had the same issue with cloud-init on Ubuntu 14.04. Rather than downgrading to Ansible 2.2.0 and reverting some of my 2.3.0-specific changes, I just ran it with:

HOME=/root ansible-playbook ...

My script works fine after that.

Not a long term solution, of course.

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 28, 2017

@avivian This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@greggilbert

This comment has been minimized.

Copy link

commented Apr 28, 2017

@ansibot bot_broken This is still an issue.

@devopsberlin

This comment has been minimized.

Copy link

commented May 15, 2017

I have the same issue on Ubuntu 16.04.2 LTS when it called from /etc/rc.local

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial
ansible 2.3.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

Error:

PLAY [local deployment] ********************************************************

TASK [Gathering Facts] *********************************************************
fatal: [127.0.0.1]: FAILED! => {"failed": true, "msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1494860388.92-38485936605401/setup.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1494860388.92-38485936605401/setup.py'"}
        to retry, use: --limit @/home/user/deploy.retry

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=1 

with HOME=/root ansible-playbook ... it works.

@jeffnappi

This comment has been minimized.

Copy link
Contributor

commented May 19, 2017

I am also experiencing this w/ AWS EC2 user-data. I was also able to get around it via HOME=/root.

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2017

@avivian This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@tamsky

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2017

I think this was introduced by #18551

This change is included in the reported version transition:
v2.2.0.0-1...v2.2.1.0-1

The change tries to fix #16032

  • ( Ansible will create a literal $HOME directory if the variable is not set )

So the HOME=/root methods to fix lines up well.

The change in the local behavior remains unexpected...

Untested theory: it interacts poorly with become/sudo, which is when HOME becomes unset.

@hehnope

This comment has been minimized.

Copy link

commented Mar 30, 2018

Unfortunately, this bug is not fixed.

Collecting ansible==2.5
  Downloading ansible-2.5.0-py2.py3-none-any.whl (7.3MB)
Collecting paramiko (from ansible==2.5)
  Downloading paramiko-2.4.1-py2.py3-none-any.whl (194kB)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python2.7/dist-packages (from ansible==2.5)
Collecting jinja2 (from ansible==2.5)
  Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting cryptography (from ansible==2.5)
  Downloading cryptography-2.2.2-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
Collecting PyYAML (from ansible==2.5)
  Downloading PyYAML-3.12.tar.gz (253kB)
Collecting pyasn1>=0.1.7 (from paramiko->ansible==2.5)
  Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB)
Collecting bcrypt>=3.1.3 (from paramiko->ansible==2.5)
  Downloading bcrypt-3.1.4-cp27-cp27mu-manylinux1_x86_64.whl (57kB)
Collecting pynacl>=1.0.1 (from paramiko->ansible==2.5)
  Downloading PyNaCl-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (696kB)
Collecting MarkupSafe>=0.23 (from jinja2->ansible==2.5)
  Downloading MarkupSafe-1.0.tar.gz
Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography->ansible==2.5)
  Downloading cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl (407kB)
Collecting enum34; python_version < "3" (from cryptography->ansible==2.5)
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography->ansible==2.5)
  Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
Collecting idna>=2.1 (from cryptography->ansible==2.5)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
Collecting six>=1.4.1 (from cryptography->ansible==2.5)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting ipaddress; python_version < "3" (from cryptography->ansible==2.5)
  Downloading ipaddress-1.0.19.tar.gz
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->ansible==2.5)
  Downloading pycparser-2.18.tar.gz (245kB)
Building wheels for collected packages: PyYAML, MarkupSafe, ipaddress, pycparser
  Running setup.py bdist_wheel for PyYAML: started
  Running setup.py bdist_wheel for PyYAML: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
  Running setup.py bdist_wheel for MarkupSafe: started
  Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
  Running setup.py bdist_wheel for ipaddress: started
  Running setup.py bdist_wheel for ipaddress: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/d7/6b/69/666188e8101897abb2e115d408d139a372bdf6bfa7abb5aef5
  Running setup.py bdist_wheel for pycparser: started
  Running setup.py bdist_wheel for pycparser: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/95/14/9a/5e7b9024459d2a6600aaa64e0ba485325aff7a9ac7489db1b6
Successfully built PyYAML MarkupSafe ipaddress pycparser
Installing collected packages: pyasn1, six, pycparser, cffi, bcrypt, enum34, asn1crypto, idna, ipaddress, cryptography, pynacl, paramiko, MarkupSafe, jinja2, PyYAML, ansible
Successfully installed MarkupSafe-1.0 PyYAML-3.12 ansible-2.5.0 asn1crypto-0.24.0 bcrypt-3.1.4 cffi-1.11.5 cryptography-2.2.2 enum34-1.1.6 idna-2.6 ipaddress-1.0.19 jinja2-2.10 paramiko-2.4.1 pyasn1-0.4.2 pycparser-2.18 pynacl-1.2.1 six-1.11.0
You are using pip version 8.1.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

PLAY [Common] ******************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [localhost]: FAILED! => {"msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1522378144.63-33629621593832/setup.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1522378144.63-33629621593832/setup.py'"}
	to retry, use: --limit @/opt/xxxx/ansible/playbooks/common.retry

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1   

@pdecat solution does work. With ansible 2.5, my current setup if I do: env ANSIBLE_LOCAL_TEMP=$HOME/.ansible/tmp ANSIBLE_REMOTE_TEMP=$HOME/.ansible/tmp /usr/local/bin/ansible-playbook -c local -i localhost, .... will allow me to use 2.5; but that's less than an ideal method (I would have to update a lot of bootstrap/infra code).

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

rbd80 added a commit to rbd80/debian_ami that referenced this issue Apr 5, 2018

@ghost

This comment has been minimized.

Copy link

commented Apr 26, 2018

Ansible 2.5.1 on my dev machine works well, but in docker container under CoreOS fails with

<xxx.xxx.xxx.xxx> SSH: EXEC scp -vvv -S none -o Port=10022 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gk -o ConnectTimeout=10 /var/jenkins_home/.ansible/tmp/ansible-local-632beRoZ_/tmpxTu_mt '[xxx.xxx.xxx.xxx]:/home/gk/.ansible/tmp/ansible-tmp-1524757845.81-168098301879483/setup.py'
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {
    "msg": "failed to transfer file to /var/jenkins_home/.ansible/tmp/ansible-local-632beRoZ_/tmpxTu_mt /home/gk/.ansible/tmp/ansible-tmp-1524757845.81-168098301879483/setup.py:\n\nExecuting: program none host xxx.xxx.xxx.xxx, user (unspecified), command scp -v -t /home/gk/.ansible/tmp/ansible-tmp-1524757845.81-168098301879483/setup.py\nnone: No such file or directory\nlost connection\n"
}
	to retry, use: --limit @/var/jenkins_home/workspace/deploy-backend/.deployment/ansible/scratch-playbook.retry

Command line looks like

ansible-playbook scratch-playbook.yml --extra-vars ansible_sudo_pass=password -i xxx.xxx.xxx.xxx,

I checked there is actually no file /var/jenkins_home/.ansible/tmp/ansible-local-632beRoZ_/tmpxTu_m

@hehnope

This comment has been minimized.

Copy link

commented Apr 26, 2018

@4xy I attempted to re-open this bug; it was closed as "not fix"; you must do this instead: env ANSIBLE_LOCAL_TEMP=$HOME/.ansible/tmp ANSIBLE_REMOTE_TEMP=$HOME/.ansible/tmp ...

It's annoying I know, but what can you do?

@vikrantjain59

This comment has been minimized.

Copy link

commented Mar 18, 2019

@avivian please run ansbile-playbook with -vvvv and paste the results here.

needs_info
fatal: [hostname]: FAILED! => {
"changed": false,
"module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 72: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 16360\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to hostname closed.\r\n",
"module_stdout": " File "/export/home/vikjain/.ansible/tmp/ansible-tmp-1552935501.28-223043348367783/AnsiballZ_setup.py", line 39\r\n with open(module, 'wb') as f:\r\n ^\r\nSyntaxError: invalid syntax\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1

@emre141

This comment has been minimized.

Copy link

commented Apr 19, 2019

Hi

I have the simillar problem to getting ansible yum module error.If my ansible role running on aws ec2 wake up using cloud-init it give me a failed yum module but after when instance become ready i logined in to the instance via ssh and manually run ansible-playbook it works well.

My cloud-init yaml

#cloud-config
write_files:

  • path: /etc/yum.repos.d/epel.repo
    content: |
    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=0

    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
    metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1

  • path: /root/install.sh
    content: |
    #!/usr/bin/env sh
    echo "BEGIN USER-DATA"
    export teamcluster='${teamcluster}'
    export asgname='${asgname}'
    #yum clean all; yum update -y ; yum install ansible
    yum clean all; yum update --disablerepo=epel -y; yum install ansible -y
    aws s3 cp s3://${bucket_name}/ansible /home/ec2-user/ansible.zip
    mkdir /root/roles; chmod 755 /root/roles
    unzip /home/ec2-user/ansible.zip -d /root/roles ; cp /root/roles/rabbitmq/files/ansible.cfg /root; cd /root
    HOME=/root ansible-playbook /root/roles/rabbitmq/tests/test.yml --connection=local --extra-vars='asgname=${asgname}'
    echo "END USER-DATA"
    runcmd:

  • export teamcluster='${teamcluster}'

  • export AWS_DEFAULT_REGION='${region}'

  • aws configure set aws_access_key_id '${aws_access_key}' --profile rabbitmq

  • aws configure set aws_secret_access_key '${aws_secret_key}' --profile rabbitmq

  • aws configure set region '${region}' --profile rabbitmq

  • bash /root/install.sh

ansible.cfg file

[defaults]
roles_path = ~/roles
library = ~/library

as we run ansible from rc.local (without proper login session),

we have to fix this issue #21562 (comment)

by explicitly specifying ansibles tmp dirs:

remote_tmp = ~/.ansible/tmp
local_tmp = ~/.ansible/tmp

My roles and ansible.cfg keep in the root home directory

[root@ip-172-16-120-168 ~]# pwd
/root
[root@ip-172-16-120-168 ~]# ls
ansible.cfg install.sh library roles
[root@ip-172-16-120-168 ~]# cat ansible.cfg
[defaults]
roles_path = ~/roles
library = ~/library

as we run ansible from rc.local (without proper login session),

we have to fix this issue #21562 (comment)

by explicitly specifying ansibles tmp dirs:

remote_tmp = ~/.ansible/tmp
local_tmp = ~/.ansible/tmp
[root@ip-172-16-120-168 ~]# ansible --version
ansible 2.7.10
config file = /root/ansible.cfg
configured module search path = [u'/root/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.14 (default, Jul 26 2018, 19:59:38) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
[root@ip-172-16-120-168 ~]#

In the CloudInit Log Output

TASK [rabbitmq : debug] ********************************************************
ok: [localhost] => {
"msg": {
"changed": false,
"failed": false,
"results": []
}
}

TASK [rabbitmq : Install rabbitmq-server package (from RabbitMQ repo)] *********
fatal: [localhost]: FAILED! => {"changed": false, "msg": "No package matching 'rabbitmq-server-3.7.10-1.el7.noarch' found available, installed or updated", "rc": 126, "resu
lts": ["No package matching 'rabbitmq-server-3.7.10-1.el7.noarch' found available, installed or updated"]}
...ignoring

TASK [rabbitmq : debug] ********************************************************
ok: [localhost] => {
"msg": {
"changed": false,
"failed": true,
"msg": "No package matching 'rabbitmq-server-3.7.10-1.el7.noarch' found available, installed or updated",
"rc": 126,
"results": [
"No package matching 'rabbitmq-server-3.7.10-1.el7.noarch' found available, installed or updated"
]
}
}

When i login to the this EC2 instance and run manullay ansible-playook to exceutre only issued tasks in my root home directory.

root@ip-172-16-120-168 ~]# ansible-playbook roles/rabbitmq/tests/test.yml --tags list,debuglist,installremoterepo,isinstall
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] ***********************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************
ok: [localhost]

TASK [rabbitmq : List ansible packages and register result to print with debug later.] *************************************************************************************
ok: [localhost]

TASK [rabbitmq : debug] ****************************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"changed": false,
"failed": false,
"results": [
{
"arch": "noarch",
"envra": "0:rabbitmq-server-3.7.10-1.el7.noarch",
"epoch": "0",
"name": "rabbitmq-server",
"release": "1.el7",
"repo": "installed",
"version": "3.7.10", "yumstate": "installed" }, { "arch": "noarch",
"envra": "0:rabbitmq-server-3.7.10-1.el7.noarch",
"epoch": "0",
"name": "rabbitmq-server",
"release": "1.el7",
"repo": "rabbit",
"version": "3.7.10",
"yumstate": "available"
}
]
}
}

TASK [rabbitmq : Install rabbitmq-server package (from RabbitMQ repo)] *****************************************************************************************************
changed: [localhost]

TASK [rabbitmq : debug] ****************************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"changed": true,
"failed": false,
"msg": "",
"rc": 0,
"results": [
"rabbitmq-server-3.7.10-1.el7.noarch providing rabbitmq-server-3.7.10-1.el7.noarch is already installed",
"Loaded plugins: extras_suggestions, langpacks, priorities, update-motd,\n : versionlock\nResolving Dependencies\n--> Running transaction check\n---> Package erlang.x86_64 0:21.0.9-1.el7.centos will be updated\n---> Package erlang.x86_64 0:21.3.3-1.el7 will be an update\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nUpdating:\n erlang x86_64 21.3.3-1.el7 erlang 18 M\n\nTransaction Summary\n================================================================================\nUpgrade 1 Package\n\nTotal download size: 18 M\nDownloading packages:\nDelta RPMs disabled because /usr/bin/applydeltarpm not installed.\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Updating : erlang-21.3.3-1.el7.x86_64 1/2 \n Cleanup : erlang-21.0.9-1.el7.centos.x86_64 2/2 \n Verifying : erlang-21.3.3-1.el7.x86_64 1/2 \n Verifying : erlang-21.0.9-1.el7.centos.x86_64 2/2 \n\nUpdated:\n erlang.x86_64 0:21.3.3-1.el7 \n\nComplete!\n"
]
}
}

PLAY RECAP *****************************************************************************************************************************************************************
localhost : ok=5 changed=1 unreachable=0 failed=0

@ansible ansible locked and limited conversation to collaborators Apr 26, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.