Skip to content
Daniel Pereira edited this page Aug 26, 2019 · 1 revision

Tips and tricks

Collection of items that might save you some time.

Using AWS modules (like aws_s3) without having to install boto3 and botocore on the host

Usually you need to install both boto3 and botocore on the host so you can utilize AWS modules. However, you can stop doing this and bundling these dependencies along with your playbook bundle.

Here's what you need to do:

  1. Package your playbook using the --python-package parameter:
$ bundle-playbook -f playbook.yml --python-package boto3 --python-package botocore
  1. On your playbook, ensure that you get the PYTHONPATH env variable coming from the available env. That is needed because Ansible modifies that variable at runtime.
- name: get something from S3
  aws_s3:
    bucket: my_s3_bucket
    object: myobject
    dest: /etc/file.cfg
    mode: get
  # Ensure you include these lines below
  environment:
    PYTHONPATH: "{{ lookup('env', 'PYTHONPATH') }}"
Clone this wiki locally