MNAIO: Ensure a consistent and readable style
This patch implements the following style changes: 1. The 'environment' argument is placed in the same location for all plays, making sure it's easier to find. 2. The play tags are located in the same place, also making sure they're easier to find. 3. The line breaks between tasks and plays are set to be consistently 1 between tasks and 2 between plays. 4. Given that there are no roles being used, the use of pre/post tasks is converted to only using tasks. Change-Id: I2e22c8360d65256b8e44ca1e310e0668a651196d
This commit is contained in:
parent
450a879403
commit
bc2ced27c2
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
hosts: pxe_hosts
|
hosts: pxe_hosts
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-acng
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -27,7 +30,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Install repo caching server packages
|
- name: Install repo caching server packages
|
||||||
package:
|
package:
|
||||||
name: "{{ mnaio_pkg_cache_server_distro_packages }}"
|
name: "{{ mnaio_pkg_cache_server_distro_packages }}"
|
||||||
@ -87,7 +89,6 @@
|
|||||||
notify:
|
notify:
|
||||||
- reload acng
|
- reload acng
|
||||||
|
|
||||||
post_tasks:
|
|
||||||
- name: Drop apt package manager proxy
|
- name: Drop apt package manager proxy
|
||||||
copy:
|
copy:
|
||||||
content: 'Acquire::http { Proxy "{{ default_ubuntu_mirror_proxy }}"; };'
|
content: 'Acquire::http { Proxy "{{ default_ubuntu_mirror_proxy }}"; };'
|
||||||
@ -97,14 +98,9 @@
|
|||||||
apt:
|
apt:
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: reload acng
|
- name: reload acng
|
||||||
service:
|
service:
|
||||||
name: "apt-cacher-ng"
|
name: "apt-cacher-ng"
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-acng
|
|
||||||
|
@ -14,7 +14,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
hosts: dhcp_hosts
|
hosts: dhcp_hosts
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-dhcpd
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -43,7 +46,6 @@
|
|||||||
enabled: yes
|
enabled: yes
|
||||||
with_items: "{{ mnaio_dhcp_distro_packages }}"
|
with_items: "{{ mnaio_dhcp_distro_packages }}"
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Create a template in /etc/dhcp/dhcpd.conf
|
- name: Create a template in /etc/dhcp/dhcpd.conf
|
||||||
template:
|
template:
|
||||||
src: dhcp/dhcpd.conf.j2
|
src: dhcp/dhcpd.conf.j2
|
||||||
@ -62,14 +64,9 @@
|
|||||||
group: root
|
group: root
|
||||||
notify: restart dhcpd
|
notify: restart dhcpd
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: restart dhcpd
|
- name: restart dhcpd
|
||||||
service:
|
service:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
with_items: "{{ mnaio_dhcp_distro_packages }}"
|
with_items: "{{ mnaio_dhcp_distro_packages }}"
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-dhcpd
|
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
- name: Setup deploy host
|
- name: Setup deploy host
|
||||||
hosts: deploy_hosts
|
hosts: deploy_hosts
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-osa
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -28,7 +31,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
tasks:
|
|
||||||
# Example read-write git checkout from github
|
# Example read-write git checkout from github
|
||||||
- name: Get OSA
|
- name: Get OSA
|
||||||
git:
|
git:
|
||||||
@ -154,8 +156,3 @@
|
|||||||
to the {{ groups['deploy_hosts'][0] }} VM and attach to the "build-osa" tmux session.
|
to the {{ groups['deploy_hosts'][0] }} VM and attach to the "build-osa" tmux session.
|
||||||
when:
|
when:
|
||||||
- run_osa | default(true) | bool
|
- run_osa | default(true) | bool
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-osa
|
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
hosts: pxe_hosts
|
hosts: pxe_hosts
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-pxe
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -69,7 +72,6 @@
|
|||||||
when:
|
when:
|
||||||
- tftp_ssh_key is undefined
|
- tftp_ssh_key is undefined
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Drop NGINX config
|
- name: Drop NGINX config
|
||||||
copy:
|
copy:
|
||||||
src: "pxe/sites-enabled.default"
|
src: "pxe/sites-enabled.default"
|
||||||
@ -211,8 +213,6 @@
|
|||||||
- "/var/lib/tftpboot"
|
- "/var/lib/tftpboot"
|
||||||
- "/var/www/pxe"
|
- "/var/www/pxe"
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: restart nginx
|
- name: restart nginx
|
||||||
service:
|
service:
|
||||||
@ -231,6 +231,3 @@
|
|||||||
name: "inetutils-inetd"
|
name: "inetutils-inetd"
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-pxe
|
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
hosts: vm_hosts
|
hosts: vm_hosts
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -28,7 +31,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Stop running VMs
|
- name: Stop running VMs
|
||||||
command: "virsh destroy {{ hostvars[item]['server_hostname'] }}"
|
command: "virsh destroy {{ hostvars[item]['server_hostname'] }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
@ -123,15 +125,13 @@
|
|||||||
- hostvars[item]['server_vm'] | default(false) | bool
|
- hostvars[item]['server_vm'] | default(false) | bool
|
||||||
with_items: "{{ groups['pxe_servers'] }}"
|
with_items: "{{ groups['pxe_servers'] }}"
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Create vm_servers group
|
- name: Create vm_servers group
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
tasks:
|
tasks:
|
||||||
- name: VM Servers group
|
- name: VM Servers group
|
||||||
add_host:
|
add_host:
|
||||||
@ -141,17 +141,12 @@
|
|||||||
- hostvars[item]['server_vm'] | default(false) | bool
|
- hostvars[item]['server_vm'] | default(false) | bool
|
||||||
with_items: "{{ groups['pxe_servers'] }}"
|
with_items: "{{ groups['pxe_servers'] }}"
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Wait for deploy host
|
- name: Wait for deploy host
|
||||||
hosts: vm_servers
|
hosts: vm_servers
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
pre_tasks:
|
tasks:
|
||||||
- name: Wait for connectivity 1
|
- name: Wait for connectivity 1
|
||||||
local_action:
|
local_action:
|
||||||
module: wait_for
|
module: wait_for
|
||||||
@ -162,7 +157,7 @@
|
|||||||
timeout: 1500
|
timeout: 1500
|
||||||
state: started
|
state: started
|
||||||
search_regex: OpenSSH
|
search_regex: OpenSSH
|
||||||
tasks:
|
|
||||||
- name: copy host keys
|
- name: copy host keys
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
@ -174,12 +169,16 @@
|
|||||||
- src: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub"
|
- src: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub"
|
||||||
dest: /root/.ssh/id_rsa.pub
|
dest: /root/.ssh/id_rsa.pub
|
||||||
|
|
||||||
|
|
||||||
# In vm-post-install-script.sh.j2 we chattr +i the interfaces file to prevent
|
# In vm-post-install-script.sh.j2 we chattr +i the interfaces file to prevent
|
||||||
# the preseed system from overwriting the file after we've modified it. The
|
# the preseed system from overwriting the file after we've modified it. The
|
||||||
# task below simply removes the immutable attribute.
|
# task below simply removes the immutable attribute.
|
||||||
- name: Remove immutable attr from /etc/network/interfaces
|
- name: Remove immutable attr from /etc/network/interfaces
|
||||||
hosts: vm_servers
|
hosts: vm_servers
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
tasks:
|
tasks:
|
||||||
- file:
|
- file:
|
||||||
path: /etc/network/interfaces
|
path: /etc/network/interfaces
|
||||||
@ -188,16 +187,14 @@
|
|||||||
- ansible_distribution | lower == "ubuntu"
|
- ansible_distribution | lower == "ubuntu"
|
||||||
- ansible_distribution_release | lower == "trusty"
|
- ansible_distribution_release | lower == "trusty"
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Set MaxSessions and MaxStartups to reduce connection failures
|
- name: Set MaxSessions and MaxStartups to reduce connection failures
|
||||||
hosts: vm_servers
|
hosts: vm_servers
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -208,7 +205,7 @@
|
|||||||
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}.yml"
|
- "{{ playbook_dir }}/vars/{{ ansible_os_family | lower }}.yml"
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
tasks:
|
|
||||||
- lineinfile:
|
- lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: MaxStartups 100
|
line: MaxStartups 100
|
||||||
@ -216,6 +213,7 @@
|
|||||||
regexp: '^MaxStartups.*$'
|
regexp: '^MaxStartups.*$'
|
||||||
notify:
|
notify:
|
||||||
- restart sshd
|
- restart sshd
|
||||||
|
|
||||||
- lineinfile:
|
- lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: MaxSessions 100
|
line: MaxSessions 100
|
||||||
@ -223,21 +221,20 @@
|
|||||||
regexp: '^MaxSessions.*$'
|
regexp: '^MaxSessions.*$'
|
||||||
notify:
|
notify:
|
||||||
- restart sshd
|
- restart sshd
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: restart sshd
|
- name: restart sshd
|
||||||
service:
|
service:
|
||||||
name: "{{ ssh_service_name }}"
|
name: "{{ ssh_service_name }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Setup cinder host volume
|
- name: Setup cinder host volume
|
||||||
hosts: cinder_hosts:swift_hosts
|
hosts: cinder_hosts:swift_hosts
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
tasks:
|
tasks:
|
||||||
- name: un-mount deleteme mount
|
- name: un-mount deleteme mount
|
||||||
mount:
|
mount:
|
||||||
@ -256,15 +253,13 @@
|
|||||||
force: true
|
force: true
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Setup cinder host volume
|
- name: Setup cinder host volume
|
||||||
hosts: cinder_hosts
|
hosts: cinder_hosts
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create cinder-volumes lv
|
- name: Create cinder-volumes lv
|
||||||
lvol:
|
lvol:
|
||||||
@ -278,15 +273,13 @@
|
|||||||
vg: cinder-volumes
|
vg: cinder-volumes
|
||||||
pvs: "/dev/vmvg00/cinder-volumes00"
|
pvs: "/dev/vmvg00/cinder-volumes00"
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
|
||||||
|
|
||||||
- name: Setup swift host volume
|
- name: Setup swift host volume
|
||||||
hosts: swift_hosts
|
hosts: swift_hosts
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- deploy-vms
|
||||||
tasks:
|
tasks:
|
||||||
- name: Remove deleteme lv
|
- name: Remove deleteme lv
|
||||||
lvol:
|
lvol:
|
||||||
@ -329,8 +322,3 @@
|
|||||||
- disk1
|
- disk1
|
||||||
- disk2
|
- disk2
|
||||||
- disk3
|
- disk3
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- deploy-vms
|
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
hosts: mnaio_hosts
|
hosts: mnaio_hosts
|
||||||
gather_facts: "{{ gather_facts | default(true) }}"
|
gather_facts: "{{ gather_facts | default(true) }}"
|
||||||
pre_tasks:
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||||
|
tags:
|
||||||
|
- setup-host
|
||||||
|
tasks:
|
||||||
- name: Gather variables for each operating system
|
- name: Gather variables for each operating system
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
@ -78,7 +81,6 @@
|
|||||||
retries: 3
|
retries: 3
|
||||||
delay: 15
|
delay: 15
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Ensure root has a .ssh directory
|
- name: Ensure root has a .ssh directory
|
||||||
file:
|
file:
|
||||||
path: /root/.ssh
|
path: /root/.ssh
|
||||||
@ -281,8 +283,3 @@
|
|||||||
echo ${module} | tee -a /etc/modules
|
echo ${module} | tee -a /etc/modules
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- setup-host
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user