From: Oleg Broytman Date: Sun, 29 Mar 2020 22:54:08 +0000 (+0300) Subject: Refactor: Move OS-specific roles under common `roles/` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=424c41462e9f4f38fdf666f2180342a8268a95c7;p=ansible.git Refactor: Move OS-specific roles under common `roles/` --- diff --git a/playbooks/debian/add-apache-vhost b/playbooks/debian/add-apache-vhost index 750f3fc..41c866c 100755 --- a/playbooks/debian/add-apache-vhost +++ b/playbooks/debian/add-apache-vhost @@ -9,6 +9,5 @@ vhost="$1" shift cd "`dirname \"$0\"`" && -ANSIBLE_ROLES_PATH=debian/roles:roles \ - exec ../run-roles add-apache-vhost "$@" \ - -e virtual_host="$vhost" -e gather_facts=true +exec ../run-roles add-apache-vhost "$@" \ + -e virtual_host="$vhost" -e gather_facts=true diff --git a/playbooks/debian/add-dns-domain b/playbooks/debian/add-dns-domain index f4d2f4a..c62fd73 100755 --- a/playbooks/debian/add-dns-domain +++ b/playbooks/debian/add-dns-domain @@ -9,6 +9,5 @@ domain="$1" shift cd "`dirname \"$0\"`" && -ANSIBLE_ROLES_PATH=debian/roles:roles \ - exec ../run-roles add-dns-domain "$@" \ - -e domain="$domain" -e gather_facts=true +exec ../run-roles add-dns-domain "$@" \ + -e domain="$domain" -e gather_facts=true diff --git a/playbooks/debian/init-system.sh b/playbooks/debian/init-system.sh index e72f318..2937b31 100755 --- a/playbooks/debian/init-system.sh +++ b/playbooks/debian/init-system.sh @@ -9,12 +9,10 @@ host="$1" shift cd "`dirname \"$0\"`" && -ANSIBLE_ROLES_PATH=roles:../roles && -export ANSIBLE_ROLES_PATH && # Passwordless access isn't configured yet; use `ssh` connection sharing. # `sudo` isn't configured yet too; use `su` and ask for root password. ansible-playbook ../init-system.yml "$@" -e hosts="$host" \ --become-method=su -K && -ANSIBLE_ROLES_PATH=debian/roles ../run-roles remove-systemd "$@" -e hosts="$host" && +../run-roles remove-systemd "$@" -e hosts="$host" && exec ansible-playbook ../init-system2.yml "$@" -e hosts="$host" diff --git a/playbooks/debian/roles/add-apache-vhost/meta/main.yml b/playbooks/debian/roles/add-apache-vhost/meta/main.yml deleted file mode 100644 index 0a640ed..0000000 --- a/playbooks/debian/roles/add-apache-vhost/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: ['apache', 'dehydrated'] diff --git a/playbooks/debian/roles/add-dns-domain/meta/main.yml b/playbooks/debian/roles/add-dns-domain/meta/main.yml deleted file mode 100644 index 6c17612..0000000 --- a/playbooks/debian/roles/add-dns-domain/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: ['named'] diff --git a/playbooks/debian/roles/apache/meta/main.yml b/playbooks/debian/roles/apache/meta/main.yml deleted file mode 100644 index 1d59f7a..0000000 --- a/playbooks/debian/roles/apache/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: ['init-system', 'firewall', 'init-logcheck'] diff --git a/playbooks/debian/roles/dehydrated/meta/main.yml b/playbooks/debian/roles/dehydrated/meta/main.yml deleted file mode 100644 index c84c3cf..0000000 --- a/playbooks/debian/roles/dehydrated/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: ['apache'] diff --git a/playbooks/debian/roles/named/meta/main.yml b/playbooks/debian/roles/named/meta/main.yml deleted file mode 100644 index 1d59f7a..0000000 --- a/playbooks/debian/roles/named/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: ['init-system', 'firewall', 'init-logcheck'] diff --git a/playbooks/init-system2.yml b/playbooks/init-system2.yml index 947fd66..e4449eb 100644 --- a/playbooks/init-system2.yml +++ b/playbooks/init-system2.yml @@ -2,7 +2,10 @@ hosts: "{{ hosts | default('all') }}" gather_facts: true roles: - - firewall + - debian/firewall + when: ansible_facts.os_family == 'Debian' + - redhat/firewall + when: ansible_facts.os_family == 'RedHat' - logcheck - root - setup-usrlocal diff --git a/playbooks/redhat/init-system.sh b/playbooks/redhat/init-system.sh index 9236165..df2f22f 100755 --- a/playbooks/redhat/init-system.sh +++ b/playbooks/redhat/init-system.sh @@ -9,8 +9,6 @@ host="$1" shift cd "`dirname \"$0\"`" && -ANSIBLE_ROLES_PATH=roles:../roles && -export ANSIBLE_ROLES_PATH && # Passwordless access isn't configured yet; use `ssh` connection sharing. # `sudo` isn't configured yet too; ask for phd password. diff --git a/playbooks/debian/roles/add-apache-vhost/README.txt b/playbooks/roles/debian/add-apache-vhost/README.txt similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/README.txt rename to playbooks/roles/debian/add-apache-vhost/README.txt diff --git a/playbooks/debian/roles/add-apache-vhost/files/dehydrated b/playbooks/roles/debian/add-apache-vhost/files/dehydrated similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/files/dehydrated rename to playbooks/roles/debian/add-apache-vhost/files/dehydrated diff --git a/playbooks/debian/roles/add-apache-vhost/handlers/main.yml b/playbooks/roles/debian/add-apache-vhost/handlers/main.yml similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/handlers/main.yml rename to playbooks/roles/debian/add-apache-vhost/handlers/main.yml diff --git a/playbooks/roles/debian/add-apache-vhost/meta/main.yml b/playbooks/roles/debian/add-apache-vhost/meta/main.yml new file mode 100644 index 0000000..ab0f395 --- /dev/null +++ b/playbooks/roles/debian/add-apache-vhost/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['debian/apache', 'debian/dehydrated'] diff --git a/playbooks/debian/roles/add-apache-vhost/tasks/add-vhost.yml b/playbooks/roles/debian/add-apache-vhost/tasks/add-vhost.yml similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/tasks/add-vhost.yml rename to playbooks/roles/debian/add-apache-vhost/tasks/add-vhost.yml diff --git a/playbooks/debian/roles/add-apache-vhost/tasks/dehydrated.yml b/playbooks/roles/debian/add-apache-vhost/tasks/dehydrated.yml similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/tasks/dehydrated.yml rename to playbooks/roles/debian/add-apache-vhost/tasks/dehydrated.yml diff --git a/playbooks/debian/roles/add-apache-vhost/tasks/main.yml b/playbooks/roles/debian/add-apache-vhost/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/tasks/main.yml rename to playbooks/roles/debian/add-apache-vhost/tasks/main.yml diff --git a/playbooks/debian/roles/add-apache-vhost/templates/dehydrated/config b/playbooks/roles/debian/add-apache-vhost/templates/dehydrated/config similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/templates/dehydrated/config rename to playbooks/roles/debian/add-apache-vhost/templates/dehydrated/config diff --git a/playbooks/debian/roles/add-apache-vhost/templates/dehydrated/domains.txt b/playbooks/roles/debian/add-apache-vhost/templates/dehydrated/domains.txt similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/templates/dehydrated/domains.txt rename to playbooks/roles/debian/add-apache-vhost/templates/dehydrated/domains.txt diff --git a/playbooks/debian/roles/add-apache-vhost/templates/vhost.conf b/playbooks/roles/debian/add-apache-vhost/templates/vhost.conf similarity index 100% rename from playbooks/debian/roles/add-apache-vhost/templates/vhost.conf rename to playbooks/roles/debian/add-apache-vhost/templates/vhost.conf diff --git a/playbooks/debian/roles/add-dns-domain/README.txt b/playbooks/roles/debian/add-dns-domain/README.txt similarity index 100% rename from playbooks/debian/roles/add-dns-domain/README.txt rename to playbooks/roles/debian/add-dns-domain/README.txt diff --git a/playbooks/roles/debian/add-dns-domain/meta/main.yml b/playbooks/roles/debian/add-dns-domain/meta/main.yml new file mode 100644 index 0000000..7b39c7e --- /dev/null +++ b/playbooks/roles/debian/add-dns-domain/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['debian/named'] diff --git a/playbooks/debian/roles/add-dns-domain/tasks/main.yml b/playbooks/roles/debian/add-dns-domain/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/add-dns-domain/tasks/main.yml rename to playbooks/roles/debian/add-dns-domain/tasks/main.yml diff --git a/playbooks/debian/roles/add-dns-domain/templates/domain b/playbooks/roles/debian/add-dns-domain/templates/domain similarity index 100% rename from playbooks/debian/roles/add-dns-domain/templates/domain rename to playbooks/roles/debian/add-dns-domain/templates/domain diff --git a/playbooks/debian/roles/apache/README.txt b/playbooks/roles/debian/apache/README.txt similarity index 100% rename from playbooks/debian/roles/apache/README.txt rename to playbooks/roles/debian/apache/README.txt diff --git a/playbooks/debian/roles/apache/files/_default_/favicon.ico b/playbooks/roles/debian/apache/files/_default_/favicon.ico similarity index 100% rename from playbooks/debian/roles/apache/files/_default_/favicon.ico rename to playbooks/roles/debian/apache/files/_default_/favicon.ico diff --git a/playbooks/debian/roles/apache/files/_default_/index.html b/playbooks/roles/debian/apache/files/_default_/index.html similarity index 100% rename from playbooks/debian/roles/apache/files/_default_/index.html rename to playbooks/roles/debian/apache/files/_default_/index.html diff --git a/playbooks/debian/roles/apache/files/_default_/nothing.html b/playbooks/roles/debian/apache/files/_default_/nothing.html similarity index 100% rename from playbooks/debian/roles/apache/files/_default_/nothing.html rename to playbooks/roles/debian/apache/files/_default_/nothing.html diff --git a/playbooks/debian/roles/apache/files/_default_/robots.txt b/playbooks/roles/debian/apache/files/_default_/robots.txt similarity index 100% rename from playbooks/debian/roles/apache/files/_default_/robots.txt rename to playbooks/roles/debian/apache/files/_default_/robots.txt diff --git a/playbooks/debian/roles/apache/files/apache2 b/playbooks/roles/debian/apache/files/apache2 similarity index 100% rename from playbooks/debian/roles/apache/files/apache2 rename to playbooks/roles/debian/apache/files/apache2 diff --git a/playbooks/debian/roles/apache/handlers/main.yml b/playbooks/roles/debian/apache/handlers/main.yml similarity index 100% rename from playbooks/debian/roles/apache/handlers/main.yml rename to playbooks/roles/debian/apache/handlers/main.yml diff --git a/playbooks/roles/debian/apache/meta/main.yml b/playbooks/roles/debian/apache/meta/main.yml new file mode 100644 index 0000000..bf5afc7 --- /dev/null +++ b/playbooks/roles/debian/apache/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['init-system', 'debian/firewall', 'debian/init-logcheck'] diff --git a/playbooks/debian/roles/apache/tasks/main.yml b/playbooks/roles/debian/apache/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/apache/tasks/main.yml rename to playbooks/roles/debian/apache/tasks/main.yml diff --git a/playbooks/debian/roles/apache/templates/001-phd.conf b/playbooks/roles/debian/apache/templates/001-phd.conf similarity index 100% rename from playbooks/debian/roles/apache/templates/001-phd.conf rename to playbooks/roles/debian/apache/templates/001-phd.conf diff --git a/playbooks/debian/roles/dehydrated/README.txt b/playbooks/roles/debian/dehydrated/README.txt similarity index 100% rename from playbooks/debian/roles/dehydrated/README.txt rename to playbooks/roles/debian/dehydrated/README.txt diff --git a/playbooks/debian/roles/dehydrated/files/dehydrated b/playbooks/roles/debian/dehydrated/files/dehydrated similarity index 100% rename from playbooks/debian/roles/dehydrated/files/dehydrated rename to playbooks/roles/debian/dehydrated/files/dehydrated diff --git a/playbooks/roles/debian/dehydrated/meta/main.yml b/playbooks/roles/debian/dehydrated/meta/main.yml new file mode 100644 index 0000000..eed76b7 --- /dev/null +++ b/playbooks/roles/debian/dehydrated/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['debian/apache'] diff --git a/playbooks/debian/roles/dehydrated/tasks/main.yml b/playbooks/roles/debian/dehydrated/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/dehydrated/tasks/main.yml rename to playbooks/roles/debian/dehydrated/tasks/main.yml diff --git a/playbooks/debian/roles/firewall/README.txt b/playbooks/roles/debian/firewall/README.txt similarity index 100% rename from playbooks/debian/roles/firewall/README.txt rename to playbooks/roles/debian/firewall/README.txt diff --git a/playbooks/debian/roles/firewall/files/etc/init.d/iptables.sh b/playbooks/roles/debian/firewall/files/etc/init.d/iptables.sh similarity index 100% rename from playbooks/debian/roles/firewall/files/etc/init.d/iptables.sh rename to playbooks/roles/debian/firewall/files/etc/init.d/iptables.sh diff --git a/playbooks/debian/roles/firewall/files/etc/init.d/rc.masq b/playbooks/roles/debian/firewall/files/etc/init.d/rc.masq similarity index 100% rename from playbooks/debian/roles/firewall/files/etc/init.d/rc.masq rename to playbooks/roles/debian/firewall/files/etc/init.d/rc.masq diff --git a/playbooks/debian/roles/firewall/files/etc/network/functions.phd b/playbooks/roles/debian/firewall/files/etc/network/functions.phd similarity index 100% rename from playbooks/debian/roles/firewall/files/etc/network/functions.phd rename to playbooks/roles/debian/firewall/files/etc/network/functions.phd diff --git a/playbooks/debian/roles/firewall/files/etc/network/if-down.d/eth b/playbooks/roles/debian/firewall/files/etc/network/if-down.d/eth similarity index 100% rename from playbooks/debian/roles/firewall/files/etc/network/if-down.d/eth rename to playbooks/roles/debian/firewall/files/etc/network/if-down.d/eth diff --git a/playbooks/debian/roles/firewall/files/etc/network/if-up.d/eth b/playbooks/roles/debian/firewall/files/etc/network/if-up.d/eth similarity index 100% rename from playbooks/debian/roles/firewall/files/etc/network/if-up.d/eth rename to playbooks/roles/debian/firewall/files/etc/network/if-up.d/eth diff --git a/playbooks/debian/roles/firewall/handlers/main.yml b/playbooks/roles/debian/firewall/handlers/main.yml similarity index 100% rename from playbooks/debian/roles/firewall/handlers/main.yml rename to playbooks/roles/debian/firewall/handlers/main.yml diff --git a/playbooks/debian/roles/firewall/tasks/main.yml b/playbooks/roles/debian/firewall/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/firewall/tasks/main.yml rename to playbooks/roles/debian/firewall/tasks/main.yml diff --git a/playbooks/debian/roles/init-logcheck/README.txt b/playbooks/roles/debian/init-logcheck/README.txt similarity index 100% rename from playbooks/debian/roles/init-logcheck/README.txt rename to playbooks/roles/debian/init-logcheck/README.txt diff --git a/playbooks/debian/roles/init-logcheck/tasks/main.yml b/playbooks/roles/debian/init-logcheck/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/init-logcheck/tasks/main.yml rename to playbooks/roles/debian/init-logcheck/tasks/main.yml diff --git a/playbooks/debian/roles/named/README.txt b/playbooks/roles/debian/named/README.txt similarity index 100% rename from playbooks/debian/roles/named/README.txt rename to playbooks/roles/debian/named/README.txt diff --git a/playbooks/debian/roles/named/files/named.conf.options b/playbooks/roles/debian/named/files/named.conf.options similarity index 100% rename from playbooks/debian/roles/named/files/named.conf.options rename to playbooks/roles/debian/named/files/named.conf.options diff --git a/playbooks/roles/debian/named/meta/main.yml b/playbooks/roles/debian/named/meta/main.yml new file mode 100644 index 0000000..bf5afc7 --- /dev/null +++ b/playbooks/roles/debian/named/meta/main.yml @@ -0,0 +1 @@ +dependencies: ['init-system', 'debian/firewall', 'debian/init-logcheck'] diff --git a/playbooks/debian/roles/named/tasks/main.yml b/playbooks/roles/debian/named/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/named/tasks/main.yml rename to playbooks/roles/debian/named/tasks/main.yml diff --git a/playbooks/debian/roles/remove-systemd/README.txt b/playbooks/roles/debian/remove-systemd/README.txt similarity index 100% rename from playbooks/debian/roles/remove-systemd/README.txt rename to playbooks/roles/debian/remove-systemd/README.txt diff --git a/playbooks/debian/roles/remove-systemd/files/etc/apt/preferences.d/no-systemd b/playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd similarity index 100% rename from playbooks/debian/roles/remove-systemd/files/etc/apt/preferences.d/no-systemd rename to playbooks/roles/debian/remove-systemd/files/etc/apt/preferences.d/no-systemd diff --git a/playbooks/debian/roles/remove-systemd/tasks/main.yml b/playbooks/roles/debian/remove-systemd/tasks/main.yml similarity index 100% rename from playbooks/debian/roles/remove-systemd/tasks/main.yml rename to playbooks/roles/debian/remove-systemd/tasks/main.yml diff --git a/playbooks/debian/roles/remove-systemd/tasks/remove-systemd.yml b/playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml similarity index 100% rename from playbooks/debian/roles/remove-systemd/tasks/remove-systemd.yml rename to playbooks/roles/debian/remove-systemd/tasks/remove-systemd.yml diff --git a/playbooks/redhat/roles/firewall/README.txt b/playbooks/roles/redhat/firewall/README.txt similarity index 100% rename from playbooks/redhat/roles/firewall/README.txt rename to playbooks/roles/redhat/firewall/README.txt diff --git a/playbooks/redhat/roles/firewall/files/etc/network/functions.phd b/playbooks/roles/redhat/firewall/files/etc/network/functions.phd similarity index 100% rename from playbooks/redhat/roles/firewall/files/etc/network/functions.phd rename to playbooks/roles/redhat/firewall/files/etc/network/functions.phd diff --git a/playbooks/redhat/roles/firewall/files/etc/network/if-down.d/eth b/playbooks/roles/redhat/firewall/files/etc/network/if-down.d/eth similarity index 100% rename from playbooks/redhat/roles/firewall/files/etc/network/if-down.d/eth rename to playbooks/roles/redhat/firewall/files/etc/network/if-down.d/eth diff --git a/playbooks/redhat/roles/firewall/files/etc/network/if-up.d/eth b/playbooks/roles/redhat/firewall/files/etc/network/if-up.d/eth similarity index 100% rename from playbooks/redhat/roles/firewall/files/etc/network/if-up.d/eth rename to playbooks/roles/redhat/firewall/files/etc/network/if-up.d/eth diff --git a/playbooks/redhat/roles/firewall/files/etc/rc.d/init.d/iptables.sh b/playbooks/roles/redhat/firewall/files/etc/rc.d/init.d/iptables.sh similarity index 100% rename from playbooks/redhat/roles/firewall/files/etc/rc.d/init.d/iptables.sh rename to playbooks/roles/redhat/firewall/files/etc/rc.d/init.d/iptables.sh diff --git a/playbooks/redhat/roles/firewall/files/etc/rc.d/init.d/rc.masq b/playbooks/roles/redhat/firewall/files/etc/rc.d/init.d/rc.masq similarity index 100% rename from playbooks/redhat/roles/firewall/files/etc/rc.d/init.d/rc.masq rename to playbooks/roles/redhat/firewall/files/etc/rc.d/init.d/rc.masq diff --git a/playbooks/redhat/roles/firewall/handlers/main.yml b/playbooks/roles/redhat/firewall/handlers/main.yml similarity index 100% rename from playbooks/redhat/roles/firewall/handlers/main.yml rename to playbooks/roles/redhat/firewall/handlers/main.yml diff --git a/playbooks/redhat/roles/firewall/tasks/main.yml b/playbooks/roles/redhat/firewall/tasks/main.yml similarity index 100% rename from playbooks/redhat/roles/firewall/tasks/main.yml rename to playbooks/roles/redhat/firewall/tasks/main.yml