Only setup/cleanup yaml config for servers (#272)
Signed-off-by: Derek Nola <derek.nola@suse.com>pull/273/head
parent
9998f503b4
commit
1c11767619
|
@ -34,8 +34,10 @@ def provision(vm, role, node_num)
|
||||||
extra_agent_args: "--node-external-ip #{node_ip} --flannel-iface eth1",
|
extra_agent_args: "--node-external-ip #{node_ip} --flannel-iface eth1",
|
||||||
# Optional, left as reference for ruby-ansible syntax
|
# Optional, left as reference for ruby-ansible syntax
|
||||||
# extra_service_envs: [ "NO_PROXY='localhost'" ],
|
# extra_service_envs: [ "NO_PROXY='localhost'" ],
|
||||||
# config_yaml: <<~YAML
|
# server_config_yaml: <<~YAML
|
||||||
# write-kubeconfig-mode: 644
|
# write-kubeconfig-mode: 644
|
||||||
|
# kube-apiserver-arg:
|
||||||
|
# - advertise-port=1234
|
||||||
# YAML
|
# YAML
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ k3s_cluster:
|
||||||
# List of locally available manifests to apply to the cluster, useful for PVCs or Traefik modifications.
|
# List of locally available manifests to apply to the cluster, useful for PVCs or Traefik modifications.
|
||||||
# extra_manifests: [ '/path/to/manifest1.yaml', '/path/to/manifest2.yaml' ]
|
# extra_manifests: [ '/path/to/manifest1.yaml', '/path/to/manifest2.yaml' ]
|
||||||
# airgap_dir: /tmp/k3s-airgap-images
|
# airgap_dir: /tmp/k3s-airgap-images
|
||||||
# config_yaml: |
|
# server_config_yaml: |
|
||||||
# This is now an inner yaml file. Maintain the indentation.
|
# This is now an inner yaml file. Maintain the indentation.
|
||||||
# YAML here will be placed as the content of /etc/rancher/k3s/config.yaml
|
# YAML here will be placed as the content of /etc/rancher/k3s/config.yaml
|
||||||
# See https://docs.k3s.io/installation/configuration#configuration-file
|
# See https://docs.k3s.io/installation/configuration#configuration-file
|
||||||
|
|
|
@ -26,3 +26,8 @@
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: "rm -rf {{ k3s_server_location }}/*"
|
cmd: "rm -rf {{ k3s_server_location }}/*"
|
||||||
removes: "{{ k3s_server_location }}/*"
|
removes: "{{ k3s_server_location }}/*"
|
||||||
|
- name: Remove K3s config
|
||||||
|
when: server_config_yaml is defined
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/rancher/k3s/config.yaml
|
||||||
|
state: absent
|
||||||
|
|
|
@ -19,6 +19,20 @@
|
||||||
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Setup optional config file
|
||||||
|
when: server_config_yaml is defined
|
||||||
|
block:
|
||||||
|
- name: Make config directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/etc/rancher/k3s"
|
||||||
|
mode: 0755
|
||||||
|
state: directory
|
||||||
|
- name: Copy config values
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ server_config_yaml }}"
|
||||||
|
dest: "/etc/rancher/k3s/config.yaml"
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: Init first server node
|
- name: Init first server node
|
||||||
# Handle both hostname OR ip address being supplied in inventory
|
# Handle both hostname OR ip address being supplied in inventory
|
||||||
when: ansible_hostname == groups['server'][0] or groups['server'][0] in ansible_facts['all_ipv4_addresses']
|
when: ansible_hostname == groups['server'][0] or groups['server'][0] in ansible_facts['all_ipv4_addresses']
|
||||||
|
@ -97,7 +111,7 @@
|
||||||
- name: Check whether kubectl is installed on control node
|
- name: Check whether kubectl is installed on control node
|
||||||
ansible.builtin.command: 'kubectl'
|
ansible.builtin.command: 'kubectl'
|
||||||
register: kubectl_installed
|
register: kubectl_installed
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
delegate_to: 127.0.0.1
|
delegate_to: 127.0.0.1
|
||||||
become: false
|
become: false
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
|
@ -205,17 +205,3 @@
|
||||||
dest: "/var/lib/rancher/k3s/server/manifests"
|
dest: "/var/lib/rancher/k3s/server/manifests"
|
||||||
mode: 0600
|
mode: 0600
|
||||||
loop: "{{ extra_manifests }}"
|
loop: "{{ extra_manifests }}"
|
||||||
|
|
||||||
- name: Setup optional config file
|
|
||||||
when: config_yaml is defined
|
|
||||||
block:
|
|
||||||
- name: Make config directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "/etc/rancher/k3s"
|
|
||||||
mode: 0755
|
|
||||||
state: directory
|
|
||||||
- name: Copy config values
|
|
||||||
ansible.builtin.copy:
|
|
||||||
content: "{{ config_yaml }}"
|
|
||||||
dest: "/etc/rancher/k3s/config.yaml"
|
|
||||||
mode: 0644
|
|
||||||
|
|
Loading…
Reference in New Issue