-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from adamcstephens/addon_refactor
refactor addons to read state and support arbitrary args
- Loading branch information
Showing
4 changed files
with
55 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
- name: Enable plugins | ||
- name: get current addons state | ||
become: yes | ||
loop: "{{ microk8s_plugins | dict2items }}" | ||
command: "microk8s.enable {{ item.key }}" | ||
loop_control: | ||
label: "{{ item.key }}" | ||
register: command_result | ||
changed_when: "'Addon ' + item.key + ' is already enabled' not in command_result.stdout" | ||
when: | ||
- item.value | ||
- item.key != "dns" | ||
- item.key != "registry" | ||
command: | ||
cmd: microk8s.status --format yaml | ||
changed_when: no | ||
register: microk8s_status | ||
|
||
- name: Disable plugins | ||
become: yes | ||
loop: "{{ microk8s_plugins | dict2items }}" | ||
command: "microk8s.disable {{ item.key }}" | ||
loop_control: | ||
label: "{{ item.key }}" | ||
register: command_result | ||
changed_when: "'Addon ' + item.key + ' is already disabled' not in command_result.stdout" | ||
when: not item.value | ||
- name: set current state fact | ||
set_fact: | ||
microk8s_status: "{{ microk8s_status.stdout | from_yaml }}" | ||
|
||
- name: Enable dns | ||
- name: enable addons | ||
become: yes | ||
command: "microk8s.enable dns:{{ microk8s_dns_resolvers }}" | ||
register: command_result | ||
changed_when: "'Addon dns is already enabled' not in command_result.stdout" | ||
loop: "{{ microk8s_status.addons }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
command: | ||
cmd: microk8s.enable {{ item.name }}{% if microk8s_plugins[item.name] != True %}:{{ microk8s_plugins[item.name] }}{% endif %} | ||
when: | ||
- "'dns' in microk8s_plugins" | ||
- microk8s_plugins.dns | ||
- item.status == 'disabled' | ||
- item.name in microk8s_plugins | ||
- microk8s_plugins[item.name] | ||
|
||
- name: Enable registry | ||
- name: disable addons | ||
become: yes | ||
command: "microk8s.enable registry:size={{ registry_size }}" | ||
register: command_result | ||
changed_when: "'Addon registry is already enabled' not in command_result.stdout" | ||
loop: "{{ microk8s_status.addons }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
command: | ||
cmd: microk8s.disable {{ item.name }} | ||
when: | ||
- "'registry' in microk8s_plugins" | ||
- microk8s_plugins.registry | ||
- item.status == 'enabled' | ||
- item.name in microk8s_plugins | ||
- not microk8s_plugins[item.name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters