Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -
- name: Create accounts.
- hosts: localhost
- vars_prompt:
- - name: "tag_start"
- prompt: "Please set the starting number for the account"
- private: no
- - name: "tag_end"
- prompt: "Please set the ending number for the account"
- private: no
- tasks:
- - name: "Emails"
- debug:
- msg: "test+{{item}}@gmail.com"
- with_sequence: start={{ tag_start }} end={{ tag_end }}
- register: email
- - name: "Account name"
- debug:
- msg: "account{{item}}"
- with_sequence: start={{ tag_start }} end={{ tag_end }}
- register: account_name
- - name: "Emails list"
- debug:
- msg: "{{email}}"
- - name: "Account names"
- debug:
- msg: "{{account_name}}"
- - name: Create AWS account
- shell: >
- aws organizations create-account --email "{{ item[0] }}"
- --account-name "{{ item[1] }}"
- --role-name admin
- --iam-user-access-to-billing ALLOW
- --profile default
- with_together:
- - "{{ email }}"
- - "{{ account_name }}"
- TASK [Emails] ********************************************************************************************************************************************************************************************************************************************************************************************************
- task path: /Users/me/repos/create_aws_account.yaml:15
- ok: [localhost] => (item=46) => {
- "msg": "test+46@gmail.com"
- }
- ok: [localhost] => (item=47) => {
- "msg": "test+47@gmail.com"
- }
- TASK [Account name] **************************************************************************************************************************************************************************************************************************************************************************************************
- task path: /Users/me/create_aws_account.yaml:21
- ok: [localhost] => (item=46) => {
- "msg": "account46"
- }
- ok: [localhost] => (item=47) => {
- "msg": "account47"
- }
- TASK [Emails] ********************************************************************************************************************************************************************************************************************************************************************************************************
- task path: /Users/me/create_aws_account.yaml:27
- ok: [localhost] => {
- "msg": {
- "changed": false,
- "msg": "All items completed",
- "results": [
- {
- "_ansible_ignore_errors": null,
- "_ansible_item_label": "46",
- "_ansible_item_result": true,
- "_ansible_no_log": false,
- "_ansible_verbose_always": true,
- "changed": false,
- "failed": false,
- "item": "46",
- "msg": "test+46@gmail.com"
- },
- {
- "_ansible_ignore_errors": null,
- "_ansible_item_label": "47",
- "_ansible_item_result": true,
- "_ansible_no_log": false,
- "_ansible_verbose_always": true,
- "changed": false,
- "failed": false,
- "item": "47",
- "msg": "test+47@gmail.com"
- }
- ]
- }
- }
- TASK [Account names] *************************************************************************************************************************************************************************************************************************************************************************************************
- task path: /Users/me/create_aws_account.yaml:31
- ok: [localhost] => {
- "msg": {
- "changed": false,
- "msg": "All items completed",
- "results": [
- {
- "_ansible_ignore_errors": null,
- "_ansible_item_label": "46",
- "_ansible_item_result": true,
- "_ansible_no_log": false,
- "_ansible_verbose_always": true,
- "changed": false,
- "failed": false,
- "item": "46",
- "msg": "account46"
- },
- {
- "_ansible_ignore_errors": null,
- "_ansible_item_label": "47",
- "_ansible_item_result": true,
- "_ansible_no_log": false,
- "_ansible_verbose_always": true,
- "changed": false,
- "failed": false,
- "item": "47",
- "msg": "account47"
- }
- ]
- }
- }
Add Comment
Please, Sign In to add comment