Skip to content

Instantly share code, notes, and snippets.

@s-hertel
Created June 29, 2018 12:46
Show Gist options
  • Save s-hertel/e03bc62e154ade758e0e9d14c8bf21e3 to your computer and use it in GitHub Desktop.
Save s-hertel/e03bc62e154ade758e0e9d14c8bf21e3 to your computer and use it in GitHub Desktop.
playbook to run a role called manage_s3
# 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 is roles/manage_s3/tasks/main.yml
---
- name: create an s3 bucket
aws_s3:
profile: "{{ profile }}"
mode: create
bucket: "{{ bucket_name }}"
---
- 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