From f4436893f15c153a266daf92f1d6a928f9927e02 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 21 Jul 2019 16:54:55 +0300 Subject: [PATCH] Feat(debian/remove-systemd): Remove SystemD --- playbooks/debian-init-system.sh | 3 +- .../roles/debian/remove-systemd/README.txt | 1 + .../files/etc/apt/preferences.d/no-systemd | 27 ++++++++++++ .../debian/remove-systemd/tasks/main.yml | 43 +++++++++++++++++++ .../remove-systemd/tasks/remove-systemd.yml | 11 +++++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 playbooks/roles/debian/remove-systemd/README.txt create mode 100644 playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd create mode 100644 playbooks/roles/debian/remove-systemd/tasks/main.yml create mode 100644 playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml diff --git a/playbooks/debian-init-system.sh b/playbooks/debian-init-system.sh index 0e5f151..8655c72 100755 --- a/playbooks/debian-init-system.sh +++ b/playbooks/debian-init-system.sh @@ -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 index 0000000..f35ae57 --- /dev/null +++ b/playbooks/roles/debian/remove-systemd/README.txt @@ -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 index 0000000..1c0f820 --- /dev/null +++ b/playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd @@ -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 index 0000000..f0dd1d6 --- /dev/null +++ b/playbooks/roles/debian/remove-systemd/tasks/main.yml @@ -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 index 0000000..dbc493d --- /dev/null +++ b/playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml @@ -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 -- 2.39.2