- name: systemd daemon-reload
  systemd:
    daemon_reload: yes


# enable or disable both... bluetooth and bt-agent
- name: 'Enable & Restart 2 services: bluetooth, bt-agent'
  systemd:
    name: "{{ item }}"
    enabled: yes
    state: restarted
  with_items:
    - bluetooth
    - bt-agent
  when: bluetooth_enabled or bluetooth_term_enabled

- name: 'Disable 2 services: bluetooth, bt-agent'
  systemd:
    name: "{{ item }}"
    enabled: no
    state: stopped
  with_items:
    - bluetooth
    - bt-agent
  when: not bluetooth_enabled and not bluetooth_term_enabled


# enable or disable bt-pan
- name: Enable & Restart 'bt-pan' service
  systemd:
    name: bt-pan
    enabled: yes
    state: restarted
  when: bluetooth_enabled

- name: Disable 'bt-pan' service
  systemd:
    name: bt-pan
    enabled: no
    state: stopped
  when: not bluetooth_enabled


# enable or disable bt-term
- name: Enable & Restart 'bt-term' service
  systemd:
    name: bt-term
    enabled: yes
    state: restarted
  when: bluetooth_term_enabled

- name: Disable 'bt-term' service
  systemd:
    name: bt-term
    enabled: no
    state: stopped
  when: not bluetooth_term_enabled
