aboutsummaryrefslogtreecommitdiffhomepage
path: root/Vagrant/bootstrap.yml
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2016-12-03 17:51:25 -0500
committerLarry Smith Jr <mrlesmithjr@gmail.com>2016-12-03 17:51:25 -0500
commit109c6b750751d1c5cd216ad2f09258cf512c4c9e (patch)
tree0b276b62a25937dd5edb6d905952cf107b7c88ca /Vagrant/bootstrap.yml
parent8f8673fb8dfa2bd4fa2694cbfdcb6eed54e502de (diff)
downloadansible-rabbitmq-109c6b750751d1c5cd216ad2f09258cf512c4c9e.tar.gz
ansible-rabbitmq-109c6b750751d1c5cd216ad2f09258cf512c4c9e.tar.zst
ansible-rabbitmq-109c6b750751d1c5cd216ad2f09258cf512c4c9e.zip
Addressed issue #6
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
Diffstat (limited to 'Vagrant/bootstrap.yml')
-rw-r--r--Vagrant/bootstrap.yml180
1 files changed, 180 insertions, 0 deletions
diff --git a/Vagrant/bootstrap.yml b/Vagrant/bootstrap.yml
new file mode 100644
index 0000000..fbd17cb
--- /dev/null
+++ b/Vagrant/bootstrap.yml
@@ -0,0 +1,180 @@
1---
2- hosts: all
3 remote_user: vagrant
4 become: true
5 vars:
6 - host_vars_directory: './host_vars'
7 - host_vars_file: '{{ host_vars_directory }}/{{ inventory_hostname }}.yml'
8 - pri_domain_name: 'vagrant.local'
9 - ssh_key_path: '.vagrant/machines/{{ inventory_hostname }}/virtualbox/private_key'
10 - update_host_vars: true
11 roles:
12 tasks:
13 - name: updating apt cache (Debian)
14 apt:
15 update_cache: yes
16 cache_valid_time: 3600
17 when: ansible_os_family == "Debian"
18
19 - name: installing ansible pre-reqs (Debian)
20 apt:
21 name: "{{ item }}"
22 state: present
23 with_items:
24 - libffi-dev
25 - libssl-dev
26 - python-dev
27 - python-setuptools
28 when: >
29 ansible_os_family == "Debian"
30
31 - name: installing epel repo (RedHat)
32 yum:
33 name: "epel-release"
34 state: present
35 when: >
36 ansible_os_family == "RedHat" and
37 ansible_distribution != "Fedora"
38
39 - name: installing ansible pre-reqs (RedHat)
40 yum:
41 name: "{{ item }}"
42 state: present
43 with_items:
44 - libffi-devel
45 - openssl-devel
46 - python-crypto
47 - python-devel
48 - python-setuptools
49 when: >
50 ansible_os_family == "RedHat" and
51 ansible_distribution != "Fedora"
52
53 - name: installing ansible pre-reqs (Fedora)
54 dnf:
55 name: "{{ item }}"
56 state: present
57 with_items:
58 - gmp-devel
59 - libffi-devel
60 - openssl-devel
61 - python-crypto
62 - python-devel
63 - python-dnf
64 - python-setuptools
65 - redhat-rpm-config
66 when: >
67 ansible_os_family == "RedHat" and
68 ansible_distribution == "Fedora"
69
70 - name: installing ansible pre-reqs (openSUSE)
71 zypper:
72 name: "{{ item }}"
73 state: present
74 with_items:
75 - gmp-devel
76 - libffi-devel
77 - openssl-devel
78 - python-crypto
79 - python-devel
80 - python-setuptools
81 when: >
82 ansible_os_family == "openSUSE Leap"
83
84 - name: installing python pip
85 easy_install:
86 name: "pip"
87 state: present
88
89 - name: installing ansible
90 pip:
91 name: "ansible"
92 state: present
93 version: 1.9.6
94
95 - name: ensuring host_vars directory exists
96 file:
97 path: "./host_vars"
98 state: directory
99 delegate_to: localhost
100 run_once: true
101 become: false
102 when: update_host_vars is defined and update_host_vars
103
104 - name: ensuring host file exists in host_vars
105 stat:
106 path: "{{ host_vars_file }}"
107 delegate_to: localhost
108 register: host_var
109 become: false
110 when: >
111 update_host_vars is defined and
112 update_host_vars
113
114 - name: creating missing host_vars
115 file:
116 path: "{{ host_vars_file }}"
117 state: touch
118 delegate_to: localhost
119 become: false
120 when: not host_var.stat.exists
121
122 - name: updating ansible_ssh_port
123 lineinfile:
124 dest: "{{ host_vars_file }}"
125 regexp: "^ansible_ssh_port{{ ':' }}"
126 line: "ansible_ssh_port{{ ':' }} 22"
127 delegate_to: localhost
128 become: false
129 when: >
130 (update_host_vars is defined and
131 update_host_vars) and
132 (ansible_eth1 is defined or
133 ansible_enp0s8 is defined)
134
135 - name: updating ansible_ssh_host
136 lineinfile:
137 dest: "{{ host_vars_file }}"
138 regexp: "^ansible_ssh_host{{ ':' }}"
139 line: "ansible_ssh_host{{ ':' }} {{ ansible_eth1.ipv4.address }}"
140 delegate_to: localhost
141 become: false
142 when: >
143 (update_host_vars is defined and
144 update_host_vars) and
145 ansible_eth1 is defined
146
147 - name: updating ansible_ssh_host
148 lineinfile:
149 dest: "{{ host_vars_file }}"
150 regexp: "^ansible_ssh_host{{ ':' }}"
151 line: "ansible_ssh_host{{ ':' }} {{ ansible_enp0s8.ipv4.address }}"
152 delegate_to: localhost
153 become: false
154 when: >
155 (update_host_vars is defined and
156 update_host_vars) and
157 ansible_enp0s8 is defined
158
159 - name: updating ansible_ssh_key
160 lineinfile:
161 dest: "{{ host_vars_file }}"
162 regexp: "^ansible_ssh_private_key_file{{ ':' }}"
163 line: "ansible_ssh_private_key_file{{ ':' }} {{ ssh_key_path }}"
164 delegate_to: localhost
165 become: false
166 when: >
167 update_host_vars is defined and
168 update_host_vars
169
170 - name: ensuring host_vars is yaml formatted
171 lineinfile:
172 dest: "{{ host_vars_file }}"
173 regexp: "---"
174 line: "---"
175 insertbefore: BOF
176 delegate_to: localhost
177 become: false
178 when: >
179 update_host_vars is defined and
180 update_host_vars