From 109c6b750751d1c5cd216ad2f09258cf512c4c9e Mon Sep 17 00:00:00 2001 From: Larry Smith Jr Date: Sat, 3 Dec 2016 17:51:25 -0500 Subject: Addressed issue #6 Signed-off-by: Larry Smith Jr --- Vagrant/roles/ansible-rabbitmq/bootstrap.yml | 152 +++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Vagrant/roles/ansible-rabbitmq/bootstrap.yml (limited to 'Vagrant/roles/ansible-rabbitmq/bootstrap.yml') diff --git a/Vagrant/roles/ansible-rabbitmq/bootstrap.yml b/Vagrant/roles/ansible-rabbitmq/bootstrap.yml new file mode 100644 index 0000000..702b540 --- /dev/null +++ b/Vagrant/roles/ansible-rabbitmq/bootstrap.yml @@ -0,0 +1,152 @@ +--- +- hosts: all + remote_user: vagrant + become: true + vars: + - host_vars_directory: './host_vars' + - host_vars_file: '{{ host_vars_directory }}/{{ inventory_hostname }}.yml' + - pri_domain_name: 'vagrant.local' + - ssh_key_path: '.vagrant/machines/{{ inventory_hostname }}/virtualbox/private_key' + - update_host_vars: true + roles: + tasks: + - name: updating apt cache (Debian) + apt: + update_cache: yes + cache_valid_time: 3600 + when: ansible_os_family == "Debian" + + - name: installing ansible pre-reqs (Debian) + apt: + name: "{{ item }}" + state: present + with_items: + - python-dev + - python-pip + when: ansible_os_family == "Debian" + + - name: installing epel repo (RedHat) + yum: + name: "epel-release" + state: present + when: > + ansible_os_family == "RedHat" and + ansible_distribution != "Fedora" + + - name: installing ansible pre-reqs (RedHat) + yum: + name: "{{ item }}" + state: present + with_items: + - python-devel + - python-dnf + - python-pip + when: > + ansible_os_family == "RedHat" and + ansible_distribution != "Fedora" + + - name: installing ansible pre-reqs (Fedora) + dnf: + name: "{{ item }}" + state: present + with_items: + - gmp-devel + - python-crypto + - python-devel + - python-dnf + - python-pip + when: > + ansible_os_family == "RedHat" and + ansible_distribution == "Fedora" + + - name: installing ansible + pip: + name: "ansible" + state: present + + - name: ensuring host_vars directory exists + file: + path: "./host_vars" + state: directory + delegate_to: localhost + run_once: true + become: false + when: update_host_vars is defined and update_host_vars + + - name: ensuring host file exists in host_vars + stat: + path: "{{ host_vars_file }}" + delegate_to: localhost + register: host_var + become: false + when: > + update_host_vars is defined and + update_host_vars + + - name: creating missing host_vars + file: + path: "{{ host_vars_file }}" + state: touch + delegate_to: localhost + become: false + when: not host_var.stat.exists + + - name: updating ansible_ssh_port + lineinfile: + dest: "{{ host_vars_file }}" + regexp: "^ansible_ssh_port{{ ':' }}" + line: "ansible_ssh_port{{ ':' }} 22" + delegate_to: localhost + become: false + when: > + (update_host_vars is defined and + update_host_vars) and + (ansible_eth1 is defined or + ansible_enp0s8 is defined) + + - name: updating ansible_ssh_host + lineinfile: + dest: "{{ host_vars_file }}" + regexp: "^ansible_ssh_host{{ ':' }}" + line: "ansible_ssh_host{{ ':' }} {{ ansible_eth1.ipv4.address }}" + delegate_to: localhost + become: false + when: > + (update_host_vars is defined and + update_host_vars) and + ansible_eth1 is defined + + - name: updating ansible_ssh_host + lineinfile: + dest: "{{ host_vars_file }}" + regexp: "^ansible_ssh_host{{ ':' }}" + line: "ansible_ssh_host{{ ':' }} {{ ansible_enp0s8.ipv4.address }}" + delegate_to: localhost + become: false + when: > + (update_host_vars is defined and + update_host_vars) and + ansible_enp0s8 is defined + + - name: updating ansible_ssh_key + lineinfile: + dest: "{{ host_vars_file }}" + regexp: "^ansible_ssh_private_key_file{{ ':' }}" + line: "ansible_ssh_private_key_file{{ ':' }} {{ ssh_key_path }}" + delegate_to: localhost + become: false + when: > + update_host_vars is defined and + update_host_vars + + - name: ensuring host_vars is yaml formatted + lineinfile: + dest: "{{ host_vars_file }}" + regexp: "---" + line: "---" + insertbefore: BOF + delegate_to: localhost + become: false + when: > + update_host_vars is defined and + update_host_vars -- cgit v1.2.3