diff --git a/playbookconfig/src/playbooks/roles/common/prepare-env/tasks/kube-extra-save-configuration.yml b/playbookconfig/src/playbooks/roles/common/prepare-env/tasks/kube-extra-save-configuration.yml index 940d0c47a..f415759eb 100644 --- a/playbookconfig/src/playbooks/roles/common/prepare-env/tasks/kube-extra-save-configuration.yml +++ b/playbookconfig/src/playbooks/roles/common/prepare-env/tasks/kube-extra-save-configuration.yml @@ -10,8 +10,35 @@ # backup is running. # - name: Read in last kubernetes config values (extraArgs and extraVolumes) - include_vars: - file: "{{ config_permdir }}/last_kube_extra_config_bootstrap.yaml" + block: + - name: Check if load has last_kube_extra_config_bootstrap.yaml + stat: + path: "{{ config_permdir }}/last_kube_extra_config_bootstrap.yaml" + register: load_has_extra_config + + - name: Read last_kube_extra_config_bootstrap.yaml if it exists + block: + + - name: Read last kubernetes config yaml file + command: "cat {{ config_permdir }}/last_kube_extra_config_bootstrap.yaml" + register: result + + - name: Get last kubernetes config facts + set_fact: + last_kube_extra_config: "{{ result.stdout | from_yaml }}" + + - name: Set last kubernetes config facts + set_fact: + apiserver_extra_args: "{{ last_kube_extra_config.apiserver_extra_args }}" + controllermanager_extra_args: "{{ last_kube_extra_config.controllermanager_extra_args }}" + scheduler_extra_args: "{{ last_kube_extra_config.scheduler_extra_args }}" + kubelet_configurations: "{{ last_kube_extra_config.kubelet_configurations }}" + apiserver_extra_volumes: "{{ last_kube_extra_config.apiserver_extra_volumes }}" + controllermanager_extra_volumes: "{{ last_kube_extra_config.controllermanager_extra_volumes }}" + scheduler_extra_volumes: "{{ last_kube_extra_config.scheduler_extra_volumes }}" + + when: load_has_extra_config.stat.exists + when: mode == 'backup' - name: Append kubernetes extra configuration (extraArgs and extraVolumes) @@ -20,17 +47,24 @@ marker: "" create: yes block: | - apiserver_extra_args: - {{ apiserver_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} - controllermanager_extra_args: - {{ controllermanager_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} - scheduler_extra_args: - {{ scheduler_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} - kubelet_configurations: - {{ kubelet_configurations | to_nice_yaml | indent(2, indentfirst=True) }} - apiserver_extra_volumes: - {{ apiserver_extra_volumes | to_yaml | indent(2, indentfirst=True) }} - controllermanager_extra_volumes: - {{ controllermanager_extra_volumes | to_yaml | indent(2, indentfirst=True) }} - scheduler_extra_volumes: - {{ scheduler_extra_volumes | to_yaml | indent(2, indentfirst=True) }} + {% if apiserver_extra_args is defined %} + apiserver_extra_args: {{ apiserver_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if controllermanager_extra_args is defined %} + controllermanager_extra_args: {{ controllermanager_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if scheduler_extra_args is defined %} + scheduler_extra_args: {{ scheduler_extra_args | to_nice_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if kubelet_configurations is defined %} + kubelet_configurations: {{ kubelet_configurations | to_nice_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if apiserver_extra_volumes is defined %} + apiserver_extra_volumes: {{ apiserver_extra_volumes | to_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if controllermanager_extra_volumes is defined %} + controllermanager_extra_volumes: {{ controllermanager_extra_volumes | to_yaml | indent(2, indentfirst=True) }} + {% endif %} + {% if scheduler_extra_volumes is defined %} + scheduler_extra_volumes: {{ scheduler_extra_volumes | to_yaml | indent(2, indentfirst=True) }} + {% endif %} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..dbea900bb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ansible==2.10.7 +jinja2==2.11.3 +markupsafe==1.1.1 +netaddr==0.8.0 diff --git a/tox.ini b/tox.ini index 31324eb78..695092ad3 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,8 @@ setenv = VIRTUAL_ENV={envdir} OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ANSIBLE_LOCAL_TEMP={toxworkdir}/.ansible/tmp -deps = -r{toxinidir}/test-requirements.txt +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt [testenv:linters] basepython = python3