Open manisnesan opened 1 year ago
Before adding the role to ansible tower, create a playbook.yml
to test it locally.
---
- hosts: 127.0.0.1
connection: local
become: true
gather_facts: true
roles:
- ir_search_user_pers_deploy
Run the playbook with this command for syntax errors ansible-playbook -K playbook.yml --syntax-check
Once it runs successfully, run the actual command ansible-playbook -K playbook.yml -v
Tip: --list-tasks
option allows to show the list of tasks and --start-at-task
to start the play from a given task instead of running the whole play. This allows to debug specific task.
Tip: --step
is another option to run a single task at a time and confirms each task before running.
Faced an issue ERROR! couldn't resolve module/action 'aws_s3'
when running aws_s3
module in the playbook. So I checked if the module is available locally by running ansible localhost -m aws_s3
and this returned
localhost | FAILED! => {
"msg": "The module aws_s3 was redirected to amazon.aws.aws_s3, which could not be loaded."
}
This indicates the module is not available since this is a community module. Hence installed the module using ansible-galaxy
command
± ansible-galaxy collection install community.aws
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/download/community-aws-5.2.0.tar.gz to /home/msivanes/.ansible/tmp/ansible-local-13648875smm6jis/tmplbcexm4z/community-aws-5.2.0-rf4j_14s
Installing 'community.aws:5.2.0' to '/home/msivanes/.ansible/collections/ansible_collections/community/aws'
Downloading https://galaxy.ansible.com/download/amazon-aws-5.2.0.tar.gz to /home/msivanes/.ansible/tmp/ansible-local-13648875smm6jis/tmplbcexm4z/amazon-aws-5.2.0-cevnhlnl
community.aws:5.2.0 was installed successfully
Installing 'amazon.aws:5.2.0' to '/home/msivanes/.ansible/collections/ansible_collections/amazon/aws'
amazon.aws:5.2.0 was installed successfully
Discovered the jupyter kernel for ansible that allows to run the playbook/tasks from Jupyter https://github.com/ansible/ansible-jupyter-kernel
Add the encrypted strings for the secrets SHARED_S3_ID and SHARED_S3_SECRET
ansible-vault encrypt_string --vault-password-file [vault file] -n [key] [value]
. Store thevault password file
in a separate vault (eg: ir-vault). Store the contents of in your local with the same file named as your vault.foo
with the value ofbar none
.ir-vault
.$ ansible-vault encrypt_string --vault-password-file ir-vault -n foo 'bar none'
foo
, this becomes your name and value.Playbook role to download files from s3 bucket