]> git.phdru.name Git - ansible.git/commitdiff
Feat(debian/remove-systemd): Remove SystemD
authorOleg Broytman <phd@phdru.name>
Sun, 21 Jul 2019 13:54:55 +0000 (16:54 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 21 Jul 2019 13:54:55 +0000 (16:54 +0300)
playbooks/debian-init-system.sh
playbooks/roles/debian/remove-systemd/README.txt [new file with mode: 0644]
playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd [new file with mode: 0644]
playbooks/roles/debian/remove-systemd/tasks/main.yml [new file with mode: 0644]
playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml [new file with mode: 0644]

index 0e5f1515fe73b6f76d1ec311150cc50aaaf41157..8655c7293f149adf7946a64776b873881217110c 100755 (executable)
@@ -4,4 +4,5 @@ cd "`dirname \"$0\"`" &&
 
 # Passwordless access isn't configured yet; use `ssh` connection sharing.
 # `sudo` isn't configured yet too; use `su` and ask for root password.
-exec ansible-playbook debian/init-system.yml "$@" --become-method=su -Kv
+ansible-playbook debian/init-system.yml "$@" --become-method=su -K &&
+exec ./run-role debian/remove-systemd "$@"
diff --git a/playbooks/roles/debian/remove-systemd/README.txt b/playbooks/roles/debian/remove-systemd/README.txt
new file mode 100644 (file)
index 0000000..f35ae57
--- /dev/null
@@ -0,0 +1 @@
+Init new Debian system: remove SystemD.
diff --git a/playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd b/playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd
new file mode 100644 (file)
index 0000000..1c0f820
--- /dev/null
@@ -0,0 +1,27 @@
+Package: systemd
+Pin: origin *
+Pin-Priority: -100
+
+Package: systemd-sysv
+Pin: origin *
+Pin-Priority: -100
+
+Package: libpam-systemd
+Pin: origin *
+Pin-Priority: -100
+
+Package: policykit
+Pin: origin *
+Pin-Priority: -100
+
+Package: policykit-1
+Pin: origin *
+Pin-Priority: -100
+
+Package: systemd-shim
+Pin: origin *
+Pin-Priority: -100
+
+Package: cgmanager
+Pin: origin *
+Pin-Priority: -100
diff --git a/playbooks/roles/debian/remove-systemd/tasks/main.yml b/playbooks/roles/debian/remove-systemd/tasks/main.yml
new file mode 100644 (file)
index 0000000..f0dd1d6
--- /dev/null
@@ -0,0 +1,43 @@
+- name: "Configure apt: pin down SystemD packages"
+  become: true
+  copy:
+    src: etc
+    dest: /
+    owner: root
+    group: root
+    mode: '0640'
+
+- name: Install SysV init
+  become: true
+  apt:
+    autoclean: yes
+    autoremove: yes
+    install_recommends: no
+    name: ['sysvinit-core', 'sysvinit-utils']
+    purge: yes
+    state: latest
+    update_cache: yes
+
+- name: Configure SysV init
+  become: true
+  copy:
+    src: /usr/share/sysvinit/inittab
+    remote_src: true
+    dest: /etc/inittab
+    owner: root
+    group: root
+    mode: '0644'
+
+- name: Purge SystemD
+  become: true
+  import_tasks: remove-systemd.yml
+  ignore_errors: true
+
+- name: Reboot if SystemD is still active
+  become: true
+  reboot:
+  when: purged.rc != 0
+
+- name: Purge SystemD after reboot
+  import_tasks: remove-systemd.yml
+  when: purged.rc != 0
diff --git a/playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml b/playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml
new file mode 100644 (file)
index 0000000..dbc493d
--- /dev/null
@@ -0,0 +1,11 @@
+- name: Purge SystemD
+  become: true
+  apt:
+    autoclean: yes
+    autoremove: yes
+    install_recommends: no
+    name: ['systemd', 'libnss-systemd']
+    purge: yes
+    state: absent
+    update_cache: no
+  register: purged