Updated command modules to use cmd argument

This commit is contained in:
Xan Manning 2021-04-10 12:15:51 +01:00
parent e5c69ec894
commit 23054c76f6
14 changed files with 48 additions and 26 deletions

View file

@ -25,7 +25,8 @@
mode: 0644
- name: Ensure HAProxy service is started
command: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
ansible.builtin.command:
cmd: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
args:
creates: /var/run/haproxy.pid

View file

@ -25,7 +25,8 @@
mode: 0644
- name: Ensure HAProxy service is started
command: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
ansible.builtin.command:
cmd: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
args:
creates: /var/run/haproxy.pid

View file

@ -1,7 +1,8 @@
---
- name: Ensure docker is installed using amazon-linux-extras
ansible.builtin.command: amazon-linux-extras install docker
ansible.builtin.command:
cmd: amazon-linux-extras install docker
args:
creates: /etc/docker
notify:

View file

@ -46,7 +46,8 @@
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
- name: Ensure Docker repository is installed and configured from file
ansible.builtin.command: yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
ansible.builtin.command:
cmd: yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
args:
creates: /etc/yum.repos.d/docker-ce.repo
when:

View file

@ -82,7 +82,8 @@
- name: Delegate an initializing control plane node
block:
- name: Lookup control node from file
ansible.builtin.command: "grep '{{ 'P_True' if (k3s_controller_list | length > 1) else 'C_True' }}' /tmp/inventory.txt"
ansible.builtin.command:
cmd: "grep '{{ 'P_True' if (k3s_controller_list | length > 1) else 'C_True' }}' /tmp/inventory.txt"
changed_when: false
check_mode: false
register: k3s_control_delegate_raw

View file

@ -1,7 +1,8 @@
---
- name: Ensure docker is uninstalled using amazon-linux-extras
ansible.builtin.command: amazon-linux-extras uninstall docker
ansible.builtin.command:
cmd: amazon-linux-extras uninstall docker
register: uninstall_docker_from_amazon_linux
changed_when: uninstall_docker_from_amazon_linux.rc == 0
become: "{{ k3s_become_for_uninstall | ternary(true, false, k3s_become_for_all) }}"

View file

@ -10,7 +10,8 @@
block:
- name: Gather a list of nodes
ansible.builtin.command: "{{ k3s_install_dir }}/kubectl get nodes"
ansible.builtin.command:
cmd: "{{ k3s_install_dir }}/kubectl get nodes"
changed_when: false
failed_when: false
delegate_to: "{{ k3s_control_delegate }}"
@ -19,11 +20,12 @@
become: "{{ k3s_become_for_kubectl | ternary(true, false, k3s_become_for_all) }}"
- name: Ensure uninstalled nodes are drained
ansible.builtin.command: >-
{{ k3s_install_dir }}/kubectl drain {{ item }}
--ignore-daemonsets
--delete-local-data
--force
ansible.builtin.command:
cmd: >-
{{ k3s_install_dir }}/kubectl drain {{ item }}
--ignore-daemonsets
--delete-local-data
--force
delegate_to: "{{ k3s_control_delegate }}"
run_once: true
when:
@ -34,7 +36,8 @@
become: "{{ k3s_become_for_kubectl | ternary(true, false, k3s_become_for_all) }}"
- name: Ensure uninstalled nodes are removed
ansible.builtin.command: "{{ k3s_install_dir }}/kubectl delete node {{ item }}"
ansible.builtin.command:
cmd: "{{ k3s_install_dir }}/kubectl delete node {{ item }}"
delegate_to: "{{ k3s_control_delegate }}"
run_once: true
when:

View file

@ -11,20 +11,23 @@
register: check_k3s_uninstall_script
- name: Check to see if docker is present
ansible.builtin.command: which docker
ansible.builtin.command:
cmd: which docker
failed_when: false
changed_when: false
register: check_k3s_docker_path
- name: Run k3s-killall.sh
ansible.builtin.command: /usr/local/bin/k3s-killall.sh
ansible.builtin.command:
cmd: /usr/local/bin/k3s-killall.sh
register: k3s_killall
changed_when: k3s_killall.rc == 0
when: check_k3s_killall_script.stat.exists
become: "{{ k3s_become_for_uninstall | ternary(true, false, k3s_become_for_all) }}"
- name: Run k3s-uninstall.sh
ansible.builtin.command: /usr/local/bin/k3s-uninstall.sh
ansible.builtin.command:
cmd: /usr/local/bin/k3s-uninstall.sh
args:
removes: /usr/local/bin/k3s-uninstall.sh
register: k3s_uninstall
@ -46,7 +49,8 @@
become: "{{ k3s_become_for_uninstall | ternary(true, false, k3s_become_for_all) }}"
- name: Clean up Docker
ansible.builtin.command: docker system prune -a --force
ansible.builtin.command:
cmd: docker system prune -a --force
when:
- ("docker" in k3s_runtime_config and k3s_runtime_config.docker)
- check_k3s_docker_path.rc == 0

View file

@ -1,7 +1,8 @@
---
- name: Check if newuidmap is available
ansible.builtin.command: which newuidmap
ansible.builtin.command:
cmd: which newuidmap
failed_when: false
changed_when: false
register: k3s_check_newuidmap_installed

View file

@ -4,7 +4,8 @@
ansible.builtin.setup:
- name: Ensure Ansible version is captured
ansible.builtin.command: ansible --version
ansible.builtin.command:
cmd: ansible --version
failed_when: false
changed_when: false
register: check_ansible_version
@ -13,7 +14,8 @@
become: false
- name: Ensure Ansible config is captured
ansible.builtin.command: ansible-config dump --only-changed
ansible.builtin.command:
cmd: ansible-config dump --only-changed
failed_when: false
changed_when: false
register: check_ansible_config
@ -22,7 +24,8 @@
become: false
- name: Ensure a list of roles is captured
ansible.builtin.command: ansible-galaxy role list
ansible.builtin.command:
cmd: ansible-galaxy role list
failed_when: false
changed_when: false
register: check_ansible_roles

View file

@ -1,7 +1,8 @@
---
- name: Check if {{ cgroup.name }} cgroup is enabled
ansible.builtin.command: grep -E "^{{ cgroup.name }}\s+.*\s+1$" /proc/cgroups
ansible.builtin.command:
cmd: 'grep -E "^{{ cgroup.name }}\s+.*\s+1$" /proc/cgroups'
failed_when: false
changed_when: false
register: k3s_check_cgroup_option

View file

@ -1,7 +1,8 @@
---
- name: Check that {{ package.name }} is installed
ansible.builtin.command: "which {{ package.name }}"
ansible.builtin.command:
cmd: "which {{ package.name }}"
changed_when: false
failed_when: false
register: check_k3s_required_package

View file

@ -1,7 +1,8 @@
---
- name: Check that all nodes to be ready
ansible.builtin.command: "{{ k3s_install_dir }}/kubectl get nodes"
ansible.builtin.command:
cmd: "{{ k3s_install_dir }}/kubectl get nodes"
changed_when: false
failed_when: kubectl_get_nodes_result.stdout.find("was refused") != -1 or
kubectl_get_nodes_result.stdout.find("ServiceUnavailable") != -1

View file

@ -1,7 +1,8 @@
---
- name: Check that k3s is not running
ansible.builtin.command: pgrep k3s
ansible.builtin.command:
cmd: pgrep k3s
failed_when:
- check_k3s_process.rc == 0
- not ansible_check_mode
@ -9,7 +10,8 @@
register: check_k3s_process
- name: Check that docker is not running
ansible.builtin.command: pgrep docker
ansible.builtin.command:
cmd: pgrep docker
failed_when:
- check_k3s_docker_process.rc == 0
- not ansible_check_mode