Cant Copy Files

748 views
Skip to first unread message

John Favorite

unread,
Aug 16, 2015, 7:34:44 PM8/16/15
to ansible...@googlegroups.com
I must be missing something really obvious but cant seem to manage copying a repo file in place. The playbook is so simple I am not sure where to start. Here is the output of some -vvvv action:

[root@localhost ansible]# ansible-playbook -vvvv -i hosts-test.ini playbook-sensu.yml

PLAY [sensu-server] *********************************************************

GATHERING FACTS ***************************************************************
<192.168.110.64> ESTABLISH CONNECTION FOR USER: centos
<192.168.110.64> REMOTE_MODULE setup
<192.168.110.64> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o IdentityFile="/root/.ssh/machine.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127 && echo $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127'
<192.168.110.64> PUT /tmp/tmpvRMQe1 TO /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/setup
<192.168.110.64> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o IdentityFile="/root/.ssh/machine.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=jynbxwsfdeohvvupaxefxoirnkumswgr] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-jynbxwsfdeohvvupaxefxoirnkumswgr; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/setup; rm -rf /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/ >/dev/null 2>&1'"'"''
ok: [192.168.110.64]

TASK: [sensu | Copy Sensu Repo configuration file] **************************
<192.168.110.64> ESTABLISH CONNECTION FOR USER: centos
<192.168.110.64> REMOTE_MODULE file src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root
<192.168.110.64> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o IdentityFile="/root/.ssh/machine.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734 && echo $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734'
<192.168.110.64> PUT /tmp/tmpqYdiro TO /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/file
<192.168.110.64> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o IdentityFile="/root/.ssh/machine.pem" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=zttsegrxwbsozarymjbqavsmkvrbbbkn] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-zttsegrxwbsozarymjbqavsmkvrbbbkn; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/file; rm -rf /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/ >/dev/null 2>&1'"'"''
failed: [192.168.110.64] => {"failed": true, "path": "/etc/yum.repos.d/sensu.repo", "state": "absent"}
msg: file (/etc/yum.repos.d/sensu.repo) is absent, cannot continue

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/root/playbook-sensu.retry

192.168.110.64             : ok=1    changed=0    unreachable=0    failed=1

Relevant ansible.cfg file:

[root@localhost ansible]# cat ansible.cfg
[defaults]
host_key_checking = False
remote_user = centos
sudo = true
private_key_file=~/.ssh/machine.pem
 

This is a CentOS 7.1 machine if it makes any difference. Any ideas?

Brian Coca

unread,
Aug 16, 2015, 7:46:48 PM8/16/15
to Ansible Project
it would help if you showed the play, as it stands it seems copy
cannot find the file.


Brian Coca

John Favorite

unread,
Aug 17, 2015, 12:31:48 AM8/17/15
to ansible...@googlegroups.com
sure thing. I have a standard dir structure laid out:

hosts-test.ini
playbook-sensu.yml
roles/
    sensu/
        tasks/
            main.yml
        templates/
        files/
            sensu.repo
I call as:
ansible-playbook -vvvv -i hosts-test.ini playbook-sensu.yml
---

- name: Copy Sensu Repo configuration file
  file: src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root

- name: Install Sensu and Dependencies
  yum: name={{ item }} state=latest
  with_items:
   - erlang
   - redis
   - sensu

- name: Install rabbitmq
  yum: name=https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.4/rabbitmq-server-3.5.4-1.noarch.rpm state=present

- name: Ensure RabbitMQ running and starts during boot
  service: name=rabbitmq-server enabled=yes state=restarted

- name: create rabbitmq vhost by hand
  rabbitmq_vhost: name=/sensu state=present 

- name: create rabbitmq stuff by hand
  rabbitmq_user: user=sensu password=sensu vhost=/sensu configure_priv=.* read_priv=.* write_priv=.*

- name: ensure redis is up and starts on boot
  service: name=redis enabled=yes state=started

- name: Copy Sensu config.json
  file: src=sensu-server-config.json dest=/etc/sensu/config.json

- name: Copy memcheck
  file: src=check_memory.json dest=/etc/sensu/conf.d/check_memory.json

- name: Copy default_handler
  file: src=default_handler.json dest=/etc/sensu/conf.d/default_handler.json

- name: Ensure sensu owns files
  file: path=/etc/sensu owner=sensu group=sensu recurse=yes

- name: Start sensu services
  service: name={{ item }} enabled=yes state=started
  with_items:
    - sensu
    - sensu-api

If I comment out the repo copy it continues on until the other copies fail. Those files are there, just didnt type them out above. Thanks for the help




Brian Coca

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8kVO0trkwwayf1YeFLObBkEmv2oCP3fzUePyjatRDdeWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Aug 17, 2015, 12:33:04 AM8/17/15
to Ansible Project
you are using the file module, when you mean to use the copy module,
change the task to this:

- name: Copy Sensu Repo configuration file
copy: src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root


--
Brian Coca

John Favorite

unread,
Aug 17, 2015, 12:50:02 AM8/17/15
to ansible...@googlegroups.com
awesome. that was it. thanks much!

Brian Coca

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages