s3 module can create a bucket, but cannot list bucket contents

17 views
Skip to first unread message

Michael Bushey

unread,
Jun 20, 2017, 8:44:33 PM6/20/17
to Ansible Project
I'm unable to get a list of an s3 bucket, Ansible says OK but no data is retrieved.

╰─➤  dpkg -l | grep boto
ii  python-boto                          2.40.0-1ubuntu1                            all          Python interface to Amazon's Web Services - Python 2.x
ii  python-boto3                         1.4.2-1                                    all          Python interface to Amazon's Web Services - Python 2.x
ii  python-botocore                      1.5.7-1                                    all          Low-level, data-driven core of boto 3 (Python 2)

╰─➤  ansible --version                                                                  
ansible 2.3.1.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]


  - name: AWS Bucket get last SQL dunp
  hosts: localhost
  gather_facts: no
  connection: local
  vars:
    bucket: myuniquebucketname
  tasks:
    - name: AWS get bucket list
      s3:
        bucket: "{{ bucket }}"
        mode: list
      register: mysqldump_list
      tags: aws, bucket

    - debug: var="{{ mysqldump_list }}"

╰─➤  ansible-playbook -i /etc/ansible/ec2.py aws_bucket_mysqltest_getlast.yml

PLAY [AWS Bucket get last SQL dunp] ***********************************************************************************************************************************************************************************************************

TASK [AWS get bucket list] ********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] **********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "<type 'dict'>": "VARIABLE IS NOT DEFINED!"
}

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

Kai Stian Olstad

unread,
Jun 21, 2017, 8:37:04 AM6/21/17
to ansible...@googlegroups.com
On 21.06.2017 02:44, Michael Bushey wrote:
> - name: AWS Bucket get last SQL dunp
> hosts: localhost
> gather_facts: no
> connection: local
> vars:
> bucket: myuniquebucketname
> tasks:
> - name: AWS get bucket list
> s3:
> bucket: "{{ bucket }}"
> mode: list
> register: mysqldump_list
> tags: aws, bucket
>
> - debug: var="{{ mysqldump_list }}"

Wrong syntax.

var= take name of the variable not the content.

- debug: var=mysqldump_list

--
Kai Stian Olstad

Michael Bushey

unread,
Jun 21, 2017, 1:01:44 PM6/21/17
to Ansible Project, ansible-pr...@olstad.com
Thank you Kai, that is exactly what I was doing wrong. Have a great day!
Reply all
Reply to author
Forward
0 new messages