Skip to content
Snippets Groups Projects
printer_host_cups_disable.yml 1.15 KiB
Newer Older
fejao's avatar
fejao committed
---
# tasks file for disabling CUPS on target system

- name: DISABLE CUPS | Populate service facts
  ansible.builtin.service_facts:

- name: DISABLE CUPS | Setting fact from cups status
  ansible.builtin.set_fact:
    cups_status: "{{ ansible_facts.services['cups.service'].status }}"
  when: ansible_facts.services['cups.service'].status is defined

- name: DISABLE CUPS | DEBUG -> Print cups_status
  ansible.builtin.debug:
    msg: "cups_status: {{ cups_status }}"
  when: c3infodesk_printer_host_cups_disable_debug | bool

- name: DISABLE CUPS | Stop the running CUPS on target
  ansible.builtin.command:
    cmd: systemctl stop cups
  become: true
  when:
    - cups_status is defined
    - cups_status != 'masked'

- name: DISABLE CUPS | Disable the running CUPS on target
  ansible.builtin.command:
    cmd: systemctl disable cups
  become: true
  # when: cups_status != 'masked'
  when:
    - cups_status is defined
    - cups_status != 'masked'

- name: DISABLE CUPS | Mask the running CUPS on target
  ansible.builtin.command:
    cmd: systemctl mask cups
  become: true
  # when: cups_status != 'masked'
  when:
    - cups_status is defined
    - cups_status != 'masked'