-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchef-json.yml
55 lines (46 loc) · 1.61 KB
/
chef-json.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
---
- name: Generate Chef custom JSON
hosts: localhost
connection: local
vars_files:
- vars/CKAN-Stack.var.yml
pre_tasks:
- name: get basic_facts
set_fact:
basic_fact={{ item }}
when: item.Environment == Environment
with_items: "{{ basic_facts }}"
- name: set facts to environment from basic_fact
set_fact: "{{ item.key }}={{ item.value }}"
with_dict: "{{ basic_fact }}"
when: basic_fact is defined
- name: Identify cloudformation stack
set_fact:
Stack_Name: "{{ item.name }}"
state: "{{ item.state }}"
template_parameters: "{{ item.template_parameters }}"
when: item.template_parameters.Environment == Environment
with_items: "{{ cloudformation_stacks }}"
- name: Describe cloudformation stack
cloudformation_facts:
region: "{{ region }}"
stack_name: "{{ Stack_Name }}"
stack_resources: true
register: stack
- name: set facts to environment from stack parameters
set_fact: "{{ item.key }}={{ item.value }}"
with_dict: "{{ stack.ansible_facts.cloudformation[Stack_Name].stack_parameters }}"
- name: Identify hosted zone cloudformation stack
set_fact:
Zone_Stack_Name: "CKAN-{{ Environment }}-hosted-zone"
- name: Describe hosted zone cloudformation stack
cloudformation_facts:
region: "{{ region }}"
stack_name: "{{ Zone_Stack_Name }}"
stack_resources: true
register: hosted_zone
tasks:
- name: Prepare chef source JSON
template:
src: chef-source.json.j2
dest: templates/chef-source.json