I am using Ubuntu Server 16.4 with ansible 2.4 on AWS
My playbook is trying to take snapshots of ec2 vol. See below
- hosts: localhost
connection: local
become: yes
become_method: sudo
gather_facts: yes
any_errors_fatal: True
- name: Take snapshots of all volume"
ec2_snapshot:
volume_id: "{{item.id}}"
description: "Taken on {{ ansible_date_time.date }}"
snapshot_tags:
frequency: hourly
with_items: "{{ aws_ec2_vol_setting }}"
I run the playbook with the following cmd
ansible-playbook -vvv pb_aws_backup_nw_us_sat.yml
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/cloud/amazon/ec2_snapshot.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: r_ansible
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036 `" && echo ansible-tmp-1517934063.54-197986659054036="` echo /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmprERpt_ TO /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036/ec2_snapshot.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036/ /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036/ec2_snapshot.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ociuiywkpfvurbbesjwxhczxoglttlsa; /usr/bin/python /home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036/ec2_snapshot.py; rm -rf "/home/r_ansible/.ansible/tmp/ansible-tmp-1517934063.54-197986659054036/" > /dev/null 2>&1'"'"' && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/cloud/amazon/ec2_snapshot.py
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
The full traceback is:
File "/tmp/ansible_gUIlz4/ansible_module_ec2_snapshot.py", line 127, in <module>
import boto.ec2
failed: [localhost] (item={u'vol': u'vol-us-sat-01', u'id': u'vol-0b6aaa3b8289580f6', u'server': u'us-nv-sat-01'}) => {
"changed": false,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"description": null,
"device_name": null,
"ec2_url": null,
"instance_id": null,
"last_snapshot_min_age": 0,
"profile": null,
"region": null,
"security_token": null,
"snapshot_id": null,
"snapshot_tags": {
"frequency": "hourly"
},
"state": "present",
"validate_certs": true,
"volume_id": "vol-0b6aaXXXXXXXX",
"wait": true,
"wait_timeout": 0
}
},
"item": {
"id": "vol-0b6aXXXXXXXXXX",
"server": "us-nv-sat-01",
"vol": "vol-us-sat-01"
},
"msg": "boto required for this module"
}
Note: The access key and secret key are empty because i am using a IAM role that is assign to the server.
I have check my host and to me at least it looks like i have all the requirements.
$ which python
/usr/bin/python
$ pip list boto | grep boto
boto (2.48.0)
boto3 (1.5.23)
botocore (1.8.37)
$ python -V
Python 2.7.12
python modules all seem to be there and importing fine is well
$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto
>>> import boto.ec2
>>> import boto3
So i am not sure why i am getting the error "boto required for this module". I have also tried without any success the solution suggested here but I still get the issue.
sudo
, please check thatboto
is visible underroot
account as well. – Konstantin Suvorov