Skip to content

Commit

Permalink
Cleanup legacy syntax, spacing, files all to yml
Browse files Browse the repository at this point in the history
Migrate older inline= syntax to pure yml syntax for module args as to be consistant with most of the rest of the tasks
Cleanup some spacing in various files
Rename some files named yaml to yml for consistancy
  • Loading branch information
Andrew Greenwood committed Feb 17, 2017
1 parent e16ebca commit ca9ea09
Show file tree
Hide file tree
Showing 45 changed files with 291 additions and 109 deletions.
3 changes: 2 additions & 1 deletion reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

pre_tasks:
- name: check confirmation
fail: msg="Reset confirmation failed"
fail:
msg: "Reset confirmation failed"
when: reset_confirmation != "yes"

roles:
Expand Down
4 changes: 3 additions & 1 deletion roles/adduser/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: User | Create User Group
group: name={{user.group|default(user.name)}} system={{user.system|default(omit)}}
group:
name: "{{user.group|default(user.name)}}"
system: "{{user.system|default(omit)}}"

- name: User | Create User
user:
Expand Down
4 changes: 3 additions & 1 deletion roles/bastion-ssh-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

- name: create ssh bastion conf
become: false
template: src=ssh-bastion.conf dest="{{ playbook_dir }}/ssh-bastion.conf"
template:
src: ssh-bastion.conf
dest: "{{ playbook_dir }}/ssh-bastion.conf"
3 changes: 2 additions & 1 deletion roles/bootstrap-os/tasks/bootstrap-centos.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---

- name: Check presence of fastestmirror.conf
stat: path=/etc/yum/pluginconf.d/fastestmirror.conf
stat:
path: /etc/yum/pluginconf.d/fastestmirror.conf
register: fastestmirror

# fastestmirror plugin actually slows down Ansible deployments
Expand Down
13 changes: 10 additions & 3 deletions roles/bootstrap-os/tasks/bootstrap-coreos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@
tags: facts

- name: Bootstrap | Copy get-pip.py
copy: src=get-pip.py dest=~/get-pip.py
copy:
src: get-pip.py
dest: ~/get-pip.py
when: (need_pip | failed)

- name: Bootstrap | Install pip
shell: "{{ansible_python_interpreter}} ~/get-pip.py"
when: (need_pip | failed)

- name: Bootstrap | Remove get-pip.py
file: path=~/get-pip.py state=absent
file:
path: ~/get-pip.py
state: absent
when: (need_pip | failed)

- name: Bootstrap | Install pip launcher
copy: src=runner dest=/opt/bin/pip mode=0755
copy:
src: runner
dest: /opt/bin/pip
mode: 0755
when: (need_pip | failed)

- name: Install required python modules
Expand Down
5 changes: 4 additions & 1 deletion roles/bootstrap-os/tasks/setup-pipelining.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
# Remove requiretty to make ssh pipelining work

- name: Remove require tty
lineinfile: regexp="^\w+\s+requiretty" dest=/etc/sudoers state=absent
lineinfile:
regexp: "^\w+\s+requiretty"
dest: /etc/sudoers
state: absent

7 changes: 5 additions & 2 deletions roles/dnsmasq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
register: dnsmasq_config

- name: Stat dnsmasq configuration
stat: path=/etc/dnsmasq.d/01-kube-dns.conf
stat:
path: /etc/dnsmasq.d/01-kube-dns.conf
register: sym

- name: Move previous configuration
Expand All @@ -49,7 +50,9 @@
state: link

- name: Create dnsmasq manifests
template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}}
template:
src: "{{item.file}}"
dest: "{{kube_config_dir}}/{{item.file}}"
with_items:
- {file: dnsmasq-ds.yml, type: ds}
- {file: dnsmasq-svc.yml, type: svc}
Expand Down
4 changes: 3 additions & 1 deletion roles/docker/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
state: restarted

- name: Docker | pause while Docker restarts
pause: seconds=10 prompt="Waiting for docker restart"
pause:
seconds: 10
prompt: "Waiting for docker restart"

- name: Docker | wait for docker
command: "{{ docker_bin_dir }}/docker images"
Expand Down
9 changes: 6 additions & 3 deletions roles/docker/tasks/set_facts_dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@
when: system_search_domains.stdout != ""

- name: check number of nameservers
fail: msg="Too many nameservers"
fail:
msg: "Too many nameservers"
when: docker_dns_servers|length > 3

- name: check number of search domains
fail: msg="Too many search domains"
fail:
msg: "Too many search domains"
when: docker_dns_search_domains|length > 6

- name: check length of search domains
fail: msg="Search domains exceeded limit of 256 characters"
fail:
msg: "Search domains exceeded limit of 256 characters"
when: docker_dns_search_domains|join(' ')|length > 256
4 changes: 3 additions & 1 deletion roles/docker/tasks/systemd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: Create docker service systemd directory if it doesn't exist
file: path=/etc/systemd/system/docker.service.d state=directory
file:
path: /etc/systemd/system/docker.service.d
state: directory

- name: Write docker proxy drop-in
template:
Expand Down
20 changes: 16 additions & 4 deletions roles/download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
when: "{{ download.enabled|bool and not download.container|bool }}"

- name: Create dest directories
file: path={{local_release_dir}}/{{download.dest|dirname}} state=directory recurse=yes
file:
path: "{{local_release_dir}}/{{download.dest|dirname}}"
state: directory
recurse: yes
when: "{{ download.enabled|bool and not download.container|bool }}"
tags: bootstrap-os

Expand Down Expand Up @@ -44,7 +47,12 @@
tags: facts

- name: Create dest directory for saved/loaded container images
file: path="{{local_release_dir}}/containers" state=directory recurse=yes mode=0755 owner={{ansible_ssh_user|default(ansible_user_id)}}
file:
path: "{{local_release_dir}}/containers"
state: directory
recurse: yes
mode: 0755
owner: "{{ansible_ssh_user|default(ansible_user_id)}}"
when: "{{ download.enabled|bool and download.container|bool }}"
tags: bootstrap-os

Expand All @@ -58,7 +66,10 @@
tags: localhost

- name: Download | create local directory for saved/loaded container images
file: path="{{local_release_dir}}/containers" state=directory recurse=yes
file:
path: "{{local_release_dir}}/containers"
state: directory
recurse: yes
delegate_to: localhost
become: false
run_once: true
Expand Down Expand Up @@ -105,7 +116,8 @@
tags: facts

- name: Stat saved container image
stat: path="{{fname}}"
stat:
path: "{{fname}}"
register: img
changed_when: false
when: "{{ download.enabled|bool and download.container|bool and download_run_once|bool }}"
Expand Down
3 changes: 2 additions & 1 deletion roles/download/tasks/set_docker_image_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
check_mode: no
when: not download_always_pull|bool

- set_fact: docker_images="{{docker_images_raw.stdout|regex_replace('\[|\]|\\n]','')|regex_replace('\s',',')}}"
- set_fact:
docker_images: "{{docker_images_raw.stdout|regex_replace('\[|\]|\\n]','')|regex_replace('\s',',')}}"
when: not download_always_pull|bool

- set_fact:
Expand Down
4 changes: 3 additions & 1 deletion roles/etcd/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
when: is_etcd_master

- name: wait for etcd up
uri: url="https://{% if is_etcd_master %}{{ etcd_address }}{% else %}127.0.0.1{% endif %}:2379/health" validate_certs=no
uri:
url: "https://{% if is_etcd_master %}{{ etcd_address }}{% else %}127.0.0.1{% endif %}:2379/health"
validate_certs: no
register: result
until: result.status is defined and result.status == 200
retries: 10
Expand Down
30 changes: 15 additions & 15 deletions roles/etcd/tasks/gen_certs_script.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: Gen_certs | create etcd cert dir
file:
path={{ etcd_cert_dir }}
group={{ etcd_cert_group }}
state=directory
owner=root
recurse=yes
path: "{{ etcd_cert_dir }}"
group: "{{ etcd_cert_group }}"
state: directory
owner: root
recurse: yes

- name: "Gen_certs | create etcd script dir (on {{groups['etcd'][0]}})"
file:
Expand All @@ -17,11 +17,11 @@

- name: "Gen_certs | create etcd cert dir (on {{groups['etcd'][0]}})"
file:
path={{ etcd_cert_dir }}
group={{ etcd_cert_group }}
state=directory
owner=root
recurse=yes
path: "{{ etcd_cert_dir }}"
group: "{{ etcd_cert_group }}"
state: directory
owner: root
recurse: yes
run_once: yes
delegate_to: "{{groups['etcd'][0]}}"

Expand Down Expand Up @@ -123,11 +123,11 @@

- name: Gen_certs | check certificate permissions
file:
path={{ etcd_cert_dir }}
group={{ etcd_cert_group }}
state=directory
owner=kube
recurse=yes
path: "{{ etcd_cert_dir }}"
group: "{{ etcd_cert_group }}"
state: directory
owner: kube
recurse: yes

- name: Gen_certs | set permissions on keys
shell: chmod 0600 {{ etcd_cert_dir}}/*key.pem
Expand Down
7 changes: 7 additions & 0 deletions roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
- include: check_certs.yml
when: cert_management == "script"
tags: [etcd-secrets, facts]

- include: gen_certs_script.yml
when: cert_management == "script"
tags: etcd-secrets

- include: sync_etcd_master_certs.yml
when: cert_management == "vault" and inventory_hostname in groups.etcd
tags: etcd-secrets

- include: sync_etcd_node_certs.yml
when: cert_management == "vault" and inventory_hostname in etcd_node_cert_hosts
tags: etcd-secrets

- include: gen_certs_vault.yml
when: cert_management == "vault" and (etcd_master_certs_needed|d() or etcd_node_certs_needed|d())
tags: etcd-secrets

- include: "install_{{ etcd_deployment_type }}.yml"
when: is_etcd_master
tags: upgrade

- include: set_cluster_health.yml
when: is_etcd_master

- include: configure.yml
when: is_etcd_master

- include: refresh_config.yml
when: is_etcd_master

Expand All @@ -50,5 +56,6 @@
# state insted of `new`.
- include: set_cluster_health.yml
when: is_etcd_master

- include: refresh_config.yml
when: is_etcd_master
9 changes: 7 additions & 2 deletions roles/kernel-upgrade/tasks/centos-7.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
---

- name: install ELRepo key
rpm_key: state=present key='{{ elrepo_key_url }}'
rpm_key:
state: present
key: '{{ elrepo_key_url }}'

- name: install elrepo repository
yum:
name: '{{elrepo_url}}'
state: present

- name: upgrade kernel
yum: name={{elrepo_kernel_package}} state=present enablerepo=elrepo-kernel
yum:
name: "{{elrepo_kernel_package}}"
state: present
enablerepo: elrepo-kernel
register: upgrade

- name: change default grub entry
Expand Down
16 changes: 13 additions & 3 deletions roles/kernel-upgrade/tasks/reboot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,33 @@
shell: nohup bash -c "sleep 5 && shutdown -r now 'Reboot required for updated kernel'" &

- name: Wait for some seconds
pause: seconds=10
pause:
seconds: 10

- set_fact:
is_bastion: "{{ inventory_hostname == 'bastion' }}"
wait_for_delegate: "localhost"

- set_fact:
wait_for_delegate: "{{hostvars['bastion']['ansible_ssh_host']}}"
when: "{{ 'bastion' in groups['all'] }}"

- name: wait for bastion to come back
wait_for: host={{ ansible_ssh_host }} port=22 delay=10 timeout=300
wait_for:
host: "{{ ansible_ssh_host }}"
port: 22
delay: 10
timeout: 300
become: false
delegate_to: localhost
when: "is_bastion"

- name: waiting for server to come back (using bastion if necessary)
wait_for: host={{ ansible_ssh_host }} port=22 delay=10 timeout=300
wait_for:
host: "{{ ansible_ssh_host }}"
port: 22
delay: 10
timeout: 300
become: false
delegate_to: "{{ wait_for_delegate }}"
when: "not is_bastion"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
tags: facts

- name: Write calico-policy-controller yaml
template: src=calico-policy-controller.yml.j2 dest={{kube_config_dir}}/calico-policy-controller.yml
template:
src: calico-policy-controller.yml.j2
dest: "{{kube_config_dir}}/calico-policy-controller.yml"
when: inventory_hostname == groups['kube-master'][0]

- name: Start of Calico policy controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
---
- name: Kubernetes Apps | Wait for kube-apiserver
uri: url=http://localhost:8080/healthz
uri:
url: http://localhost:8080/healthz
register: result
until: result.status == 200
retries: 10
delay: 6
when: inventory_hostname == groups['kube-master'][0]

- name: Kubernetes Apps | Lay Down KubeDNS Template
template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}}
template:
src: "{{item.file}}"
dest: "{{kube_config_dir}}/{{item.file}}"
with_items:
- {file: kubedns-rc.yml, type: rc}
- {file: kubedns-svc.yml, type: svc}
Expand Down
Loading

0 comments on commit ca9ea09

Please sign in to comment.