Skip to content

Commit

Permalink
feat: move playbooks to playbooks directory to fully qualified name r…
Browse files Browse the repository at this point in the history
…eferences (techno-tim#557)
  • Loading branch information
ednxzu committed Aug 9, 2024
1 parent 635f0b2 commit 8e33725
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

ansible-playbook site.yml
ansible-playbook techno_tim.k3s_ansible.site.yml
2 changes: 1 addition & 1 deletion molecule/resources/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
- name: Converge
ansible.builtin.import_playbook: ../../site.yml
ansible.builtin.import_playbook: techno_tim.k3s_ansible.site.yml
2 changes: 1 addition & 1 deletion molecule/resources/reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
- name: Reset
ansible.builtin.import_playbook: ../../reset.yml
ansible.builtin.import_playbook: techno_tim.k3s_ansible.reset.yml
10 changes: 10 additions & 0 deletions playbooks/reboot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Reboot k3s_cluster
hosts: k3s_cluster
gather_facts: true
tasks:
- name: Reboot the nodes (and Wait upto 5 mins max)
become: true
reboot:
reboot_command: "{{ custom_reboot_command | default(omit) }}"
reboot_timeout: 300
25 changes: 25 additions & 0 deletions playbooks/reset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Reset k3s cluster
hosts: k3s_cluster
gather_facts: true
roles:
- role: reset
become: true
- role: raspberrypi
become: true
vars: {state: absent}
post_tasks:
- name: Reboot and wait for node to come back up
become: true
reboot:
reboot_command: "{{ custom_reboot_command | default(omit) }}"
reboot_timeout: 3600

- name: Revert changes to Proxmox cluster
hosts: proxmox
gather_facts: true
become: true
remote_user: "{{ proxmox_lxc_ssh_user }}"
roles:
- role: reset_proxmox_lxc
when: proxmox_lxc_configure
68 changes: 68 additions & 0 deletions playbooks/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Pre tasks
hosts: all
pre_tasks:
- name: Verify Ansible is version 2.11 or above. (If this fails you may need to update Ansible)
assert:
that: "ansible_version.full is version_compare('2.11', '>=')"
msg: >
"Ansible is out of date. See here for more info: https://docs.technotim.live/posts/ansible-automation/"
- name: Prepare Proxmox cluster
hosts: proxmox
gather_facts: true
become: true
environment: "{{ proxy_env | default({}) }}"
roles:
- role: proxmox_lxc
when: proxmox_lxc_configure

- name: Prepare k3s nodes
hosts: k3s_cluster
gather_facts: true
environment: "{{ proxy_env | default({}) }}"
roles:
- role: lxc
become: true
when: proxmox_lxc_configure
- role: prereq
become: true
- role: download
become: true
- role: raspberrypi
become: true
- role: k3s_custom_registries
become: true
when: custom_registries

- name: Setup k3s servers
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server
become: true

- name: Setup k3s agents
hosts: node
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_agent
become: true

- name: Configure k3s cluster
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server_post
become: true

- name: Storing kubeconfig in the playbook directory
hosts: master
environment: "{{ proxy_env | default({}) }}"
tasks:
- name: Copying kubeconfig from {{ hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname'] }}
ansible.builtin.fetch:
src: "{{ ansible_user_dir }}/.kube/config"
dest: ./kubeconfig
flat: true
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
2 changes: 1 addition & 1 deletion reboot.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

ansible-playbook reboot.yml
ansible-playbook techno_tim.k3s_ansible.reboot.yml
2 changes: 1 addition & 1 deletion reset.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

ansible-playbook reset.yml
ansible-playbook techno_tim.k3s_ansible.reset.yml

0 comments on commit 8e33725

Please sign in to comment.