mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
05c8bb79f8
The playbook is already running in jenkins and works. This moves the assets into core for ease of maintenance going forward.
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
- name: Launch Instance
|
|
ec2:
|
|
group_id: 'sg-07bb906d' # jenkins-slave_new
|
|
count: 1
|
|
instance_type: 'm3.medium'
|
|
image: '{{ item.image }}'
|
|
wait: true
|
|
region: 'us-east-1'
|
|
keypair: '{{ keypair }}'
|
|
aws_access_key: "{{ aws_access_key|default(lookup('env', 'AWS_ACCESS_KEY')) }}"
|
|
aws_secret_key: "{{ aws_secret_key|default(lookup('env', 'AWS_SECRET_KEY')) }}"
|
|
instance_tags:
|
|
jenkins: jenkins_ansible_pr_test
|
|
register: ec2
|
|
with_items: slaves
|
|
# We could do an async here, that would speed things up
|
|
|
|
|
|
- name: Wait for SSH
|
|
wait_for:
|
|
host: "{{ item['instances'][0]['public_ip'] }}"
|
|
port: 22
|
|
delay: 10
|
|
timeout: 320
|
|
state: started
|
|
with_items: ec2.results
|
|
|
|
- name: Wait a little longer for centos
|
|
pause: seconds=20
|
|
|
|
- name: Add hosts group temporary inventory group with pem path
|
|
add_host:
|
|
name: "{{ item.1.platform }} {{ ec2.results[item.0]['instances'][0]['public_ip'] }}"
|
|
groups: dynamic_hosts
|
|
ansible_ssh_host: "{{ ec2.results[item.0]['instances'][0]['public_ip'] }}"
|
|
ansible_ssh_private_key_file: '{{ pem_path }}'
|
|
ansible_ssh_user: "{{ item.1.ssh_user }}"
|
|
ec2_vars: "{{ ec2.results[item.0]['instances'][0] }}"
|
|
ec2_instance_ids: "{{ ec2.results[item.0]['instance_ids'] }}"
|
|
with_indexed_items: slaves
|
|
|