How do I write Ansible task for ‘systemctl set-default’ without shell/command modules

When you execute systemctl set-default you can see this log

Removed symlink /etc/systemd/system/ 
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/

Then you can use file module to create symlink as below

- name: Change default target
  hosts: all
  become: yes
  gather_facts: no

  - name: Change default target to
      src: /usr/lib/systemd/system/
      dest: /etc/systemd/system/
      state: link

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top