I succeeded in creating an EC2 instance by using the ansible.playbook action.
I wanted to create a workflow to pass EC2 instances created with this playbook to new actions.
However, after ansible execution ends, it is not linked to the next task.
How can I solve it?
[Playbook]
- name: "create ec2 instance"
ec2:
instance_tags:
Name: "{{ ec2.name }}"
key_name: "{{ keypair.name }}"
instance_type: "{{ ec2.instance_type }}"
image: "{{ ec2.image }}"
wait: yes
group: "{{ secgrp.name }}"
count: 1
vpc_subnet_id: "{{ vpc_regst.subnet.id }}"
assign_public_ip: yes
register: ec2_regst
[workflow]
tasks:
task1:
action: ansible.playbook
input:
playbook: <% $.param %>
publish:
instance_id: ec2_regst.instances[0].id
ec2rr: ec2_regst
on-success:
- task2
task2:
action: core.local
input:
cmd: "echo '$ <% $ %> $.param: <% $.param %>, $.instance_id: <% $.instance_id %>, $.ec2err: <% $.ec2err %>'"