forked from mrlesmithjr/vagrant-ansible-routing-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.yml
74 lines (64 loc) · 2.6 KB
/
bootstrap.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
---
- hosts: all
remote_user: vagrant
sudo: yes
vars:
- galaxy_roles:
- mrlesmithjr.bootstrap
- mrlesmithjr.base
- mrlesmithjr.quagga
- install_galaxy_roles: true
- ssh_key_path: '.vagrant/machines/{{ inventory_hostname }}/virtualbox/private_key'
- update_host_vars: true
roles:
tasks:
- name: updating apt cache
apt: update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: installing ansible pre-reqs
apt: name={{ item }} state=present
with_items:
- python-pip
- python-dev
when: ansible_os_family == "Debian"
- name: adding ansible ppa
apt_repository: repo='ppa:ansible/ansible'
when: ansible_os_family == "Debian"
- name: installing ansible
apt: name=ansible state=latest
when: ansible_os_family == "Debian"
- name: installing ansible-galaxy roles
shell: ansible-galaxy install {{ item }} --force
with_items: galaxy_roles
when: install_galaxy_roles is defined and install_galaxy_roles
- name: ensuring host file exists in host_vars
stat: path=./host_vars/{{ inventory_hostname }}
delegate_to: localhost
register: host_var
sudo: false
when: update_host_vars is defined and update_host_vars
- name: creating missing host_vars
file: path=./host_vars/{{ inventory_hostname }} state=touch
delegate_to: localhost
sudo: false
when: not host_var.stat.exists
- name: updating ansible_ssh_port
lineinfile: dest=./host_vars/{{ inventory_hostname }} regexp="^ansible_ssh_port{{ ':' }}" line="ansible_ssh_port{{ ':' }} 22"
delegate_to: localhost
sudo: false
when: update_host_vars is defined and update_host_vars
- name: updating ansible_ssh_host
lineinfile: dest=./host_vars/{{ inventory_hostname }} regexp="^ansible_ssh_host{{ ':' }}" line="ansible_ssh_host{{ ':' }} {{ ansible_eth1.ipv4.address }}"
delegate_to: localhost
sudo: false
when: update_host_vars is defined and update_host_vars
- name: updating ansible_ssh_key
lineinfile: dest=./host_vars/{{ inventory_hostname }} regexp="^ansible_ssh_private_key_file{{ ':' }}" line="ansible_ssh_private_key_file{{ ':' }} {{ ssh_key_path }}"
delegate_to: localhost
sudo: false
when: update_host_vars is defined and update_host_vars
- name: ensuring host_vars is yaml formatted
lineinfile: dest=./host_vars/{{ inventory_hostname }} regexp="---" line="---" insertbefore=BOF
delegate_to: localhost
sudo: false
when: update_host_vars is defined and update_host_vars