add ansible_setup role for k3s nodes

master
Michael Wilson 3 years ago
parent 5158851a0d
commit 11df09ca92
  1. 3
      linux/k3s/ansible_setup/defaults/main.yml
  2. 27
      linux/k3s/ansible_setup/tasks/main.yml

@ -0,0 +1,3 @@
k3s_collections_to_install:
- kubernetes.core
kube_config: /etc/rancher/k3s/k3s.yaml

@ -0,0 +1,27 @@
- name: install ansible python package
ansible.builtin.pip:
name: ansible
- name: Create a directory if it does not exist
ansible.builtin.file:
path: ~/.kube
state: directory
mode: '0700'
owner: "{{ ansible_user }}"
- name: copy kube config to ansible home dir
copy:
src: /etc/rancher/k3s/k3s.yaml
dest: ~/.kube/config
mode: '0600'
owner: "{{ ansible_user }}"
remote_src: yes
become: yes
- name: install necessary ansible collections
community.general.ansible_galaxy_install:
type: collection
name: "{{ collection_name }}"
loop: "{{ k3s_ansible_collections }}"
loop_control:
loop_var: collection_name
Loading…
Cancel
Save