-
Notifications
You must be signed in to change notification settings - Fork 7
/
guided.yml
executable file
·97 lines (87 loc) · 3.05 KB
/
guided.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/local/bin/ansible-playbook --inventory=inventory
- name: ' Konductor | Devkit | Build VPC'
hosts: local
vars:
module: "build"
state_provider: "local"
tf_module_path: "{{ dir_terraform }}/devkit-vpc"
ansible_name_module: " Konductor | Devkit VPC | {{ module }}"
vars_files:
- vars/global.yml
vars_prompt:
- name: cloud_region
prompt: "Please enter your AWS region"
private: no
- name: cluster_name
prompt: "Please enter your AWS VPC Name"
private: no
- name: aws_access_key
prompt: "Please enter your AWS Access Key ID"
private: no
- name: aws_secret_key
prompt: "Please enter your AWS Access Key Secret"
private: no
- name: cluster_domain
prompt: "Please enter the top level Domain space"
private: no
- name: rhcos_ami
prompt: "Please enter the rhcos ami id"
private: no
- name: ssh_public_key
prompt: "Please enter the aws public key string"
private: no
- name: aws_ssh_key
prompt: "Please enter the aws ssh key name"
private: no
tasks:
- name: '{{ ansible_name_module }} | file | Create ~/.aws'
file:
path: "/root/.aws"
state: directory
####### Stage Variables & AWS Creds
- name: '{{ ansible_name_module }} | template | Terraform Vars & aws credentials'
template:
src: "{{ item.name }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
- { mode: '755', name: "templates/terraform/global.tfvars.j2", dest: "{{ tf_module_path }}/global.tfvars"}
- { mode: '600', name: "templates/aws/credentials.j2", dest: "{{ local_home }}/.aws/credentials"}
####### Symlinks
- name: '{{ ansible_name_module }} | variable | Create Provider symlink'
file:
src: "{{ tf_module_path }}/provider.tf"
dest: "{{ item }}"
state: link
loop:
- "{{ tf_module_path }}/vpc/provider.tf"
- "{{ tf_module_path }}/security-groups/provider.tf"
####### Terraform Init
- name: '{{ ansible_name_module }} | shell | terraform init'
shell: terraform init
loop:
- "{{ tf_module_path }}"
####### Terraform Apply
- name: '{{ ansible_name_module }} | terraform | apply'
terraform:
project_path: "{{ tf_module_path }}"
variables_file: "{{ tf_module_path }}/global.tfvars"
force_init: true
state: present
register: tf_output
# ####### Purge SSH known_hosts entries if previous entries found
# - name: '{{ ansible_name_module }} | lineinfile | purge previous known_hosts entries'
# lineinfile:
# dest: "{{ local_home }}/.ssh/known_hosts"
# regexp: "{{ item.regex }}"
# state: absent
# with_items:
# - { regex: ensign }
# - { regex: '{{ tf_output.outputs.public_ipv4.value }}' }
#
# ####### Declare result & public address of instance
# - name: 'Ensign Public IP Address'
# debug:
# msg:
# - "New instance created at the following ip address:"
# - "{{ tf_output.outputs.public_ipv4.value }}"