Hi! currently I'm working on a playbook that creates an AWS cloudformation 
stack, then gets the ips of the created instances and run some commands on 
them.

I have this project structure:

- main.yml
- create_cloudformation_stack.yml
- post_cfdeploy_tasks.yml
- roles/
  - ...... (some private developed roles to get aws credentials, they work 
ok)
- group_vars/
  - tag_someName_someKey.yml


main.yml looks like this:
---
- include: create_cloudformation_stack.yml
- include: post_cfdeploy_tasks.yml


This is create_cloudformation_stack.yml file:
---
- name: Deploy Aws Cloudformation Stack
  hosts: localhost
  roles:
    - aws_credentials
  tasks:
    - name: Deploys yaml stack on S3
      cloudformation:
        stack_name: "{{ AWS_CLOUD_NAME }}"
        state: "present"
        aws_access_key: "{{ AWS_ACCESS_KEY_ID }}"
        aws_secret_key: "{{ AWS_SECRET_ACCESS_KEY }}"
        region: "{{ AWS_REGION }}"
        template_url: "{{ TEMPLATE_URL }}"
        tags:
          someName: "someKey"
      register: stack
    - debug: 
        msg: "{{ stack.stack_outputs }}"


This is post_cfdeploy_tasks.yml
- name: Excecutes rake migration on every ECS host
  hosts: tag_someName_someKey
  roles:
    - aws_credentials
  tasks:
    - name: Get container id
      shell: docker ps | grep "test-website" | cut -d " " -f1
      register: containerID
    - name: Migrate db
      command: docker exec -i "{{ containerID.stdout }}" 
/usr/local/bin/bundle exec rake db:migrate
      register: containers
    - debug: msg="{{ containers.stdout }}"

All those curly braced variables are stored in vault and work awesome. The 
problem I'm having is that I can't create the cloudformation stack and get 
the AWS hosts with the dynamic inventory in the same play. I have to create 
the cloudformation in one run and then run the post deploy playbook 
manually. I'm running the playbook like this:
AWS_PROFILE=someUserProfile ansible-playbook main.yml --ask-vault-pass -i 
"roles/aws_inventory/files/ec2.py"

What can be happening here?

It may be a bug, I would like to help. Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2be5d181-ca2a-4d98-bea3-dfa34e44c9c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to