register: vhost_conf
changed_when: not vhost_conf.stat.exists
-- name: Add vhost
- import_tasks: add-vhost.yml
- when: not vhost_conf.stat.exists
-
-- name: Run dehydrated for the vhost
- import_tasks: dehydrated.yml
+- block:
+ - name: Add vhost
+ import_tasks: add-vhost.yml
+ - name: Run dehydrated for the vhost
+ import_tasks: dehydrated.yml
when: not vhost_conf.stat.exists
register: domain_exists
changed_when: not domain_exists.stat.exists
-- name: Copy domain template
- become: true
- template:
- src: domain
- dest: "/etc/bind/{{ domain }}"
- owner: bind
- group: bind
- mode: '0600'
- force: no
- when: not domain_exists.stat.exists
-
-- name: Update config
- become: true
- shell: |
- echo 'zone "{{ domain }}" {
- type master;
- file "/etc/bind/{{ domain }}";
- allow-query { any; };
- notify yes;
- };' >> /etc/bind/named.conf.local
+- block:
+ - name: Copy domain template
+ become: true
+ template:
+ src: domain
+ dest: "/etc/bind/{{ domain }}"
+ owner: bind
+ group: bind
+ mode: '0600'
+ force: no
+ - name: Update config
+ become: true
+ shell: |
+ echo 'zone "{{ domain }}" {
+ type master;
+ file "/etc/bind/{{ domain }}";
+ allow-query { any; };
+ notify yes;
+ };' >> /etc/bind/named.conf.local
- when: not domain_exists.stat.exists
-- name: Reload BIND
- become: true
- service:
- name: bind9
- state: reloaded
+ - name: Reload BIND
+ become: true
+ service:
+ name: bind9
+ state: reloaded
when: not domain_exists.stat.exists
msg: "apache has already been configured"
when: phd_conf.stat.exists
-- name: Install apache
- become: true
- apt:
- autoclean: yes
- autoremove: yes
- install_recommends: no
- name: apache2
- purge: yes
- state: latest
- update_cache: yes
- when: not phd_conf.stat.exists
+- block:
+ - name: Install apache
+ become: true
+ apt:
+ autoclean: yes
+ autoremove: yes
+ install_recommends: no
+ name: apache2
+ purge: yes
+ state: latest
+ update_cache: yes
-- name: Enable SSL module
- become: true
- command: a2enmod ssl
- notify: Reload apache
- when: not phd_conf.stat.exists
+ - name: Enable SSL module
+ become: true
+ command: a2enmod ssl
+ notify: Reload apache
-- name: Configure apache
- become: true
- template:
- src: 001-phd.conf
- dest: /etc/apache2/conf-available
- owner: root
- group: root
- mode: '0640'
- force: no
- when: not phd_conf.stat.exists
+ - name: Configure apache
+ become: true
+ template:
+ src: 001-phd.conf
+ dest: /etc/apache2/conf-available
+ owner: root
+ group: root
+ mode: '0640'
+ force: no
-- name: Enable config
- become: true
- command: a2enconf 001-phd
- notify: Reload apache
+ - name: Enable config
+ become: true
+ command: a2enconf 001-phd
+ notify: Reload apache
when: not phd_conf.stat.exists
- name: Configure logrotate
register: dehydrated
changed_when: not dehydrated.stat.exists
-- name: Install git
- local_action:
- module: apt
- autoclean: yes
- autoremove: yes
- install_recommends: no
- name: git
- purge: yes
- state: latest
- update_cache: yes
- when: not dehydrated.stat.exists
+- block:
+ - name: Install git
+ become: true
+ local_action:
+ module: apt
+ autoclean: yes
+ autoremove: yes
+ install_recommends: no
+ name: git
+ purge: yes
+ state: latest
+ update_cache: yes
-- name: Prepare to clone dehydrated
- local_action:
- module: file
- path: /usr/local/src/LetsEncrypt
- state: directory
- when: not dehydrated.stat.exists
+ - name: Prepare to clone dehydrated
+ local_action:
+ module: file
+ path: /usr/local/src/LetsEncrypt
+ state: directory
-- name: Clone dehydrated
- local_action:
- module: git
- repo: https://github.com/lukas2511/dehydrated.git
- dest: /usr/local/src/LetsEncrypt/dehydrated
+ - name: Clone dehydrated
+ local_action:
+ module: git
+ repo: https://github.com/lukas2511/dehydrated.git
+ dest: /usr/local/src/LetsEncrypt/dehydrated
when: not dehydrated.stat.exists
- name: Prepare the server to syncronize dehydrated
msg: "Locales have already been configured"
when: has_locales.stdout != "0"
-- name: Configure locales
- become: true
- lineinfile:
- path: /etc/locale.gen
- regexp: "^{{ item }}"
- line: "{{ item }}"
- loop: [
- 'en_US ISO-8859-1',
- 'ru_RU.KOI8-R KOI8-R',
- 'ru_RU.UTF-8 UTF-8',
- ]
- when: has_locales.stdout == "0"
-
-- name: Regenerate locales
- become: true
- command: /usr/sbin/locale-gen
+- block:
+ - name: Configure locales
+ become: true
+ lineinfile:
+ path: /etc/locale.gen
+ regexp: "^{{ item }}"
+ line: "{{ item }}"
+ loop: [
+ 'en_US ISO-8859-1',
+ 'ru_RU.KOI8-R KOI8-R',
+ 'ru_RU.UTF-8 UTF-8',
+ ]
+ - name: Regenerate locales
+ become: true
+ command: /usr/sbin/locale-gen
when: has_locales.stdout == "0"
msg: "BIND has already been configured"
when: named_conf.stdout not in ('', "0")
-- name: Install BIND
- become: true
- apt:
- autoclean: yes
- autoremove: yes
- install_recommends: no
- name: bind9
- purge: yes
- state: latest
- update_cache: yes
- when: named_conf.stdout in ('', "0")
+- block:
+ - name: Install BIND
+ become: true
+ apt:
+ autoclean: yes
+ autoremove: yes
+ install_recommends: no
+ name: bind9
+ purge: yes
+ state: latest
+ update_cache: yes
-- name: Configure BIND
- become: true
- copy:
- src: named.conf.options
- dest: /etc/bind/named.conf.options
- owner: bind
- group: bind
- mode: '0600'
- when: named_conf.stdout in ('', "0")
+ - name: Configure BIND
+ become: true
+ copy:
+ src: named.conf.options
+ dest: /etc/bind/named.conf.options
+ owner: bind
+ group: bind
+ mode: '0600'
-- name: Reload BIND
- become: true
- service:
- name: bind9
- state: reloaded
+ - name: Reload BIND
+ become: true
+ service:
+ name: bind9
+ state: reloaded
when: named_conf.stdout in ('', "0")
- name: Purge SystemD
import_tasks: remove-systemd.yml
-- name: Reboot if SystemD is still active
- become: true
- reboot:
- when: "'rc' in purged and purged.rc != 0"
-
-- name: Purge SystemD after reboot
- import_tasks: remove-systemd.yml
+- block:
+ - name: Reboot if SystemD is still active
+ become: true
+ reboot:
+ - name: Purge SystemD after reboot
+ import_tasks: remove-systemd.yml
when: "'rc' in purged and purged.rc != 0"
msg: "mc links have already been created"
when: links_exist.results|selectattr('stat.exists')|selectattr('stat.islnk')|list|length == 3
-- name: "Setup root mc - create directories for mc links"
- become: true
- file:
- path: "~root/{{ item }}"
- state: directory
- mode: "0700"
- loop: ['.cache', '.config', '.local/share']
- when: links_exist.results|selectattr('stat.exists')|selectattr('stat.islnk')|list|length != 3
+- block:
+ - name: "Setup root mc - create directories for mc links"
+ become: true
+ file:
+ path: "~root/{{ item }}"
+ state: directory
+ mode: "0700"
+ loop: ['.cache', '.config', '.local/share']
-- name: "Setup root mc - remove mc directories"
- become: true
- file:
- path: "~root/{{ item }}"
- state: absent
- loop: ['.cache/mc', '.config/mc', '.local/share/mc']
- when: links_exist.results|selectattr('stat.exists')|selectattr('stat.islnk')|list|length != 3
+ - name: "Setup root mc - remove mc directories"
+ become: true
+ file:
+ path: "~root/{{ item }}"
+ state: absent
+ loop: ['.cache/mc', '.config/mc', '.local/share/mc']
-- name: "Setup root mc - link mc directories (1)"
- become: true
- file:
- path: "~root/{{ item }}"
- state: link
- src: "../.mc"
- force: yes
- loop: ['.cache/mc', '.config/mc']
- when: links_exist.results|selectattr('stat.exists')|selectattr('stat.islnk')|list|length != 3
+ - name: "Setup root mc - link mc directories (1)"
+ become: true
+ file:
+ path: "~root/{{ item }}"
+ state: link
+ src: "../.mc"
+ force: yes
+ loop: ['.cache/mc', '.config/mc']
-- name: "Setup root mc - link mc directories (2)"
- become: true
- file:
- path: "~root/{{ item }}"
- state: link
- src: "../../.mc"
- force: yes
- loop: ['.local/share/mc']
+ - name: "Setup root mc - link mc directories (2)"
+ become: true
+ file:
+ path: "~root/{{ item }}"
+ state: link
+ src: "../../.mc"
+ force: yes
+ loop: ['.local/share/mc']
when: links_exist.results|selectattr('stat.exists')|selectattr('stat.islnk')|list|length != 3
- name: "Setup root mc - overwrite files from ~phd/admin"