-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.yaml
58 lines (54 loc) · 1.92 KB
/
play.yaml
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
- name: Provision a compute instance
hosts: localhost
gather_facts: no
become: no
vars:
os_config_file: "{{ lookup('env', 'OS_CLIENT_CONFIG_FILE') }}"
os_auth:
project_name: "{{ lookup('env', 'OS_PROJECT') }}"
auth_url: "{{ lookup('env', 'OS_AUTH_URL') }}"
username: "{{ lookup('env', 'OS_USERNAME') }}"
password: "{{ lookup('env', 'OS_PASSWORD') }}"
vars_files:
- test_vars.yml
tasks:
- name: Load Tower cloud credential config when it is present
include_vars: "{{ os_config_file }}"
when: os_config_file != ''
- name: Set necessary variables when Tower cloud credential config is present
set_fact:
os_auth:
auth_url: "{{ clouds.devstack.auth.auth_url }}"
username: "{{ clouds.devstack.auth.username }}"
password: "{{ clouds.devstack.auth.password }}"
project_name: "{{ clouds.devstack.auth.project_name }}"
when: os_config_file != ''
- name: Fail if fallback environment variables are not set
fail:
msg: "missing required environment variable: '{{ item }}'"
when: os_config_file == '' and lookup('env', item) is undefined
with_items:
- OS_AUTH_URL
- OS_USERNAME
- OS_PASSWORD
- OS_PROJECT
- name: echo with fruits
debug: msg="number of apples {{ item.value.apple }}, number of banaa {{ item.value.banana }}"
with_dict: "{{ fruits }}"
- name: echo with vegitables
debug: msg="number of tomato {{ item.value.tomato }}, number of potato {{ item.value.potato }}"
with_dict: "{{ vegitables }}"
- name: Launch compute instances
os_server:
auth: "{{ os_auth }}"
name: compute-node-demo
auto_ip: no
image: rhel-7.2
flavor: m1.small
key_name: demo-key
nics:
- net-name: direct
security_groups:
- ssh
wait: no
state: present