mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-22 02:07:46 +07:00
style(metal): fix Ansible lint
This commit is contained in:
parent
9ae548d7dd
commit
cb87bbc690
@ -57,6 +57,7 @@ spec:
|
||||
- ansible-lint
|
||||
args:
|
||||
- -v
|
||||
- --force-color
|
||||
- name: yaml
|
||||
command:
|
||||
- yamllint
|
||||
|
@ -1,4 +1,4 @@
|
||||
ansible_user: root
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519
|
||||
ssh_public_key: "{{lookup('file', '~/.ssh/id_ed25519.pub') }}"
|
||||
ssh_public_key: "{{ lookup('file', '~/.ssh/id_ed25519.pub') }}"
|
||||
dns_server: "8.8.8.8"
|
||||
|
@ -1,17 +1,17 @@
|
||||
- name: Install packages for automatic upgrade
|
||||
dnf:
|
||||
ansible.builtin.dnf:
|
||||
name:
|
||||
- dnf-automatic
|
||||
- dnf-utils
|
||||
|
||||
- name: Copy automatic upgrade config file
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: automatic.conf
|
||||
dest: /etc/dnf/automatic.conf
|
||||
mode: 0644
|
||||
|
||||
- name: Enable automatic upgrade service
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: dnf-automatic.timer
|
||||
state: started
|
||||
enabled: true
|
||||
|
@ -1,14 +1,15 @@
|
||||
- name: Download k3s binary
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s
|
||||
checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-amd64.txt
|
||||
dest: "{{ role_path }}/files/bin/k3s"
|
||||
mode: 0755
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
register: k3s_binary
|
||||
|
||||
- name: Copy k3s binary to nodes
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: bin/k3s
|
||||
dest: /usr/local/bin/k3s
|
||||
owner: root
|
||||
@ -16,7 +17,7 @@
|
||||
mode: 0755
|
||||
|
||||
- name: Ensure config directories exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
@ -26,32 +27,32 @@
|
||||
|
||||
- name: Check if k3s token file exists on the first node
|
||||
run_once: true
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ k3s_token_file }}"
|
||||
register: k3s_token_file_stat
|
||||
|
||||
- name: Generate k3s token file on the first node if not exist yet
|
||||
run_once: true
|
||||
when: not k3s_token_file_stat.stat.exists
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ lookup('community.general.random_string', length=32) }}"
|
||||
dest: "{{ k3s_token_file }}"
|
||||
mode: 0600
|
||||
|
||||
- name: Get k3s token from the first node
|
||||
run_once: true
|
||||
slurp:
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ k3s_token_file }}"
|
||||
register: k3s_token_base64
|
||||
|
||||
- name: Ensure all nodes has the same token
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ k3s_token_base64.content | b64decode }}"
|
||||
dest: "{{ k3s_token_file }}"
|
||||
mode: 0600
|
||||
|
||||
- name: Copy k3s config files
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: 0644
|
||||
@ -62,7 +63,7 @@
|
||||
dest: "{{ k3s_service_file }}"
|
||||
|
||||
- name: Enable k3s service
|
||||
systemd:
|
||||
ansible.builtin.systemd:
|
||||
name: k3s
|
||||
enabled: true
|
||||
state: started
|
||||
@ -72,12 +73,12 @@
|
||||
|
||||
- name: Get Kubernetes config file
|
||||
run_once: true
|
||||
slurp:
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/rancher/k3s/k3s.yaml
|
||||
register: kubeconfig_base64
|
||||
|
||||
- name: Write Kubernetes config file with the correct cluster address
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ kubeconfig_base64.content | b64decode | replace('127.0.0.1', hostvars[groups['masters'][0]].ansible_host) }}"
|
||||
dest: "{{ playbook_dir }}/kubeconfig.yaml"
|
||||
mode: 0600
|
||||
|
@ -1,36 +1,37 @@
|
||||
- name: Download boot image
|
||||
get_url:
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ iso_url }}"
|
||||
dest: "{{ role_path }}/files/data/iso/{{ iso_url | basename }}"
|
||||
checksum: "{{ iso_checksum }}"
|
||||
mode: 0644
|
||||
register: iso
|
||||
|
||||
- name: Extract boot image
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: "xorriso -osirrox on -indev {{ iso.dest }} -extract / {{ role_path }}/files/data/os"
|
||||
creates: "{{ role_path }}/files/data/os/.treeinfo"
|
||||
|
||||
- name: Generate DHCP config
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: dhcpd.conf.j2
|
||||
dest: "{{ role_path }}/files/data/pxe-config/dhcpd.conf"
|
||||
mode: 0644
|
||||
|
||||
- name: Generate GRUB config
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: grub.cfg.j2
|
||||
dest: "{{ role_path }}/files/data/pxe-config/grub.cfg"
|
||||
mode: 0644
|
||||
|
||||
- name: Generate init config for each machine
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: kickstart.ks.j2
|
||||
dest: "{{ role_path }}/files/data/init-config/{{ hostvars[item]['mac'] }}.ks"
|
||||
mode: 0644
|
||||
loop: "{{ groups['metal'] }}"
|
||||
|
||||
- name: Start the ephemeral PXE server
|
||||
docker_compose:
|
||||
community.docker.docker_compose:
|
||||
project_src: "{{ role_path }}/files"
|
||||
state: present
|
||||
restarted: true
|
||||
|
@ -4,5 +4,5 @@
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Wait for the machines to come online
|
||||
wait_for_connection:
|
||||
ansible.builtin.wait_for_connection:
|
||||
timeout: 600
|
||||
|
Loading…
Reference in New Issue
Block a user