Created
June 29, 2018 12:46
-
-
Save s-hertel/e03bc62e154ade758e0e9d14c8bf21e3 to your computer and use it in GitHub Desktop.
playbook to run a role called manage_s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# structure: | |
playbook.yml # Yaml file to run | |
roles # A directory | |
manage_s3 # A directory for the role named manage_s3 | |
tasks # A directory | |
main.yml # The place where the role starts | |
# can have other playbooks to include in main.yml here | |
# Can also have a directory for vars, files, templates, etc: see https://docs.ansible.com/ansible/2.5/user_guide/playbooks_reuse_roles.html | |
# Can also have other roles here | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is roles/manage_s3/tasks/main.yml | |
--- | |
- name: create an s3 bucket | |
aws_s3: | |
profile: "{{ profile }}" | |
mode: create | |
bucket: "{{ bucket_name }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: yourhosts | |
tasks: | |
# ... | |
- name: loop over included role to create an S3 bucket | |
include_role: | |
name: manage_s3 | |
vars: | |
profile: "{{ item.profile }}" | |
bucket_name: "bucketname-{{ item.bucket_suffix }}" | |
loop: | |
- {'profile': 'shertel', 'bucket_suffix': 'dev'} | |
- {'profile': 'default', 'bucket_suffix': 'demo'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment