-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcfme-ec2.yml
82 lines (80 loc) · 2.31 KB
/
cfme-ec2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
- name: Provision ec2 instances based on the environment
hosts: localhost
connection: local
gather_facts: False
vars_files:
- roles/ec2/vars/aws_creds.yml
vars:
provider_id: 34
tasks:
- name: Provision simple instance
ec2:
ec2_access_key: "{{ ec2_access_key }}"
ec2_secret_key: "{{ ec2_secret_key }}"
region: ap-southeast-2
key_name: aws_keys
group: default
instance_type: t2.micro
image: ami-e0c19f83
wait: true
count: "{{ instance_count }}"
count_tag:
Name: Demo
instance_tags:
Name: Demo
register: ec2
- name: Wait for machines to come up completely
wait_for: host={{ item.public_dns_name }} port=22
with_items: '{{ec2.instances}}'
# - name: Set provider URL
# set_fact:
# provider_url: "{{ manageiq.api_url }}/api/providers/{{ provider_id }}"
# - name: Refresh Amazon EC2 provider in CloudForms
# uri:
# url: "{{ provider_url }}"
# method: POST
# body:
# action: refresh
# body_format: json
# validate_certs: False
# headers:
# X-Auth-Token: "{{ manageiq.api_token }}"
# Content-Type: "application/json"
# status_code: 200
# register: output
# - name: Set the task href
# set_fact:
# task_url: "{{ output.json.task_href}}"
# - debug:
# var: output.json.task_href
# - name: Wait for the provider refresh to end
# uri:
# url: "{{ task_url }}"
# method: GET
# validate_certs: False
# headers:
# X-Auth-Token: "{{ manageiq.api_token }}"
# Content-Type: "application/json"
# status_code: 200
# register: task_result
# until: task_result.json.state == 'Finished' or task_result.json.status == 'Error'
# failed_when: task_result.json.status == 'Error'
# #retries: "{{max_retries}}"
# #delay: "{{retry_interval}}"
# - name: Lookup instance href
# uri:
# url: "{{ manageiq.api_url }}/api/vms?filter[]=name={{ item.id }}&expand=resources"
# method: GET
# body:
# action: refresh
# body_format: json
# validate_certs: False
# headers:
# X-Auth-Token: "{{ manageiq.api_token }}"
# Content-Type: "application/json"
# status_code: 200
# register: output
# with_items:
# - "{{ ec2.instances }}"
# - debug:
# var: output.results