Skip to content

Commit

Permalink
reorganize code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
suhancz committed May 29, 2024
1 parent 70ffce2 commit 5b51577
Show file tree
Hide file tree
Showing 55 changed files with 86 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tasks/ssl.yml schema[tasks] # no idea why the linter complains on this one, the whole thing works
tasks/security/ssl.yml schema[tasks] # no idea why the linter complains on this one, the whole thing works
meta/main.yml schema[meta] # the platform EL version 8 does exist - not sure why the linter complains about it
defaults/main.yaml jinja[spacing] # the current setup makes the schema more readable
4 changes: 2 additions & 2 deletions tasks/backups.yml → tasks/backups/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@
register: start_ldap_server
changed_when: start_ldap_server.rc == 0
- name: Restore service tarball backups
ansible.builtin.include_tasks: restore_service_tarball_backup.yml
ansible.builtin.include_tasks: backups/restore_service_tarball_backup.yml
vars:
service: cyrus-imap
service_backup_path: "{{ imap_backup_path }}"
- name: Restore service tarball backups
ansible.builtin.include_tasks: restore_service_tarball_backup.yml
ansible.builtin.include_tasks: backups/restore_service_tarball_backup.yml
vars:
service: "{{ item }}"
service_backup_path: "{{ vars[item ~ '_backup_path'] }}"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
tags:
- dyndns
- poweradmin
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{% if dyndns_item | length > 0 %}dyndns.{% endif %}{{ mailserver_domain }}"
Expand All @@ -15,7 +15,7 @@
tags:
- dyndns
- poweradmin
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{% if dyndns_item | length > 0 %}{{ wg_configs[dyndns_item]['owner'] }}.{% endif %}dyndns.{{ mailserver_domain }}"
Expand All @@ -27,7 +27,7 @@
tags:
- dyndns
- poweradmin
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{% if dyndns_item | length > 0 %}{{ wg_configs[dyndns_item]['owner'] }}.{% endif %}dyndns.{{ mailserver_domain }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Fill default CNAME records
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{{ dns_zone }}"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tasks/dns_records.yml → tasks/dns/dns_records.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
register: set_primary_zone
changed_when: set_primary_zone.rc == 0
- name: Fill DNS zone
ansible.builtin.include_tasks: fill_default_dns_records.yml
ansible.builtin.include_tasks: dns/fill_default_dns_records.yml
vars:
dns_zone: "{{ item }}"
loop: "{{ [mailserver_domain] + custom_domains }}"
when: public_dns == "yes" and ((reset == "yes") or (item not in all_dns_zones.stdout_lines))
- name: Create default CNAME records
ansible.builtin.include_tasks: create_default_cname_records.yml
ansible.builtin.include_tasks: dns/create_default_cname_records.yml
vars:
dns_zone: "{{ item }}"
loop: "{{ [mailserver_domain] + custom_domains + ['vpn.' ~ mailserver_domain] }}"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions tasks/dyndns.yml → tasks/dns/dyndns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
tags:
- dyndns
- poweradmin
ansible.builtin.import_tasks: add_dns_record.yml
ansible.builtin.import_tasks: dns/add_dns_record.yml
vars:
record:
zone: "dyndns.{{ mailserver_domain }}"
Expand All @@ -140,7 +140,7 @@
tags:
- dyndns
- poweradmin
ansible.builtin.import_tasks: add_dns_record.yml
ansible.builtin.import_tasks: dns/add_dns_record.yml
vars:
record:
zone: "dyndns.{{ mailserver_domain }}"
Expand All @@ -153,7 +153,7 @@
- dyndns
- poweradmin
- users
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
when: dyndns_item != "server"
vars:
record:
Expand All @@ -171,7 +171,7 @@
- dyndns
- poweradmin
- users
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "dyndns.{{ mailserver_domain }}"
Expand All @@ -183,7 +183,7 @@
loop_control:
loop_var: dyndns_item
- name: Configure DynDNS subdomains
ansible.builtin.include_tasks: configure_dyndns_subdomain.yml
ansible.builtin.include_tasks: dns/configure_dyndns_subdomain.yml
when: dyndns_item != "server"
loop: "{{ [''] + (wg_configs.keys() | list) }}"
loop_control:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Fill default DNS records
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
empty_apostrophes: "''"
record:
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions tasks/dns.yml → tasks/dns/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
- name: Open firewall
ansible.builtin.import_tasks: firewall.yml
ansible.builtin.import_tasks: security/firewall.yml
vars:
port: dns # noqa var-naming[no-reserved] we refer to a port here, so I call it a port
when: 'public_dns == "yes"'
- name: Configure local DNS cache
ansible.builtin.import_tasks: local_dns_cache.yml
ansible.builtin.import_tasks: dns/local_dns_cache.yml
- name: Configure PowerDNS
ansible.builtin.import_tasks: pdns.yml
ansible.builtin.import_tasks: dns/pdns.yml
- name: Set up DNS records
ansible.builtin.import_tasks: dns_records.yml
ansible.builtin.import_tasks: dns/dns_records.yml
- name: Configure PowerDNS recursor
ansible.builtin.import_tasks: pdns_recursor.yml
ansible.builtin.import_tasks: dns/pdns_recursor.yml
- name: Configure DNSDist
ansible.builtin.import_tasks: dnsdist.yml
ansible.builtin.import_tasks: dns/dnsdist.yml
- name: Make sure PowerDNS is running
ansible.builtin.systemd_service:
name: pdns
Expand All @@ -35,7 +35,7 @@
state: started
when: 'public_dns == "yes"'
- name: Configure PowerAdmin
ansible.builtin.import_tasks: poweradmin.yml
ansible.builtin.import_tasks: dns/poweradmin.yml
tags:
- dyndns
- poweradmin
4 changes: 2 additions & 2 deletions tasks/pdns.yml → tasks/dns/pdns.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Create PowerDNS DB
ansible.builtin.import_tasks: create_mariadb_schema.yml
ansible.builtin.import_tasks: mariadb/create_mariadb_schema.yml
vars:
mariadb_database: powerdnsdb
mariadb_state: "{{ ('import' if reset == 'yes')|default('present') }}"
Expand All @@ -16,7 +16,7 @@
no_log: yes
when: 'public_dns == "yes"'
# - name: Fill PowerDNS DB with data
# ansible.builtin.import_tasks: fill_mariadb_data.yml
# ansible.builtin.import_tasks: mariadb/fill_mariadb_data.yml
# vars:
# mariadb_database:
# db: powerdnsdb
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
desired_dkim_record: "{{ dkim_keys.stdout.replace(dkim_selector ~ '._domainkey\tIN\tTXT\t( \"', '').replace('\t', '').replace('\n', '').replace('\" \"', '').replace('\" ) ; ----- DKIM key ' ~ dkim_selector ~ ' for ' ~ domain_item, '') }}" # noqa no-tabs we need tabs in this content
current_dkim_record: "{{ lookup('community.general.dig', dkim_selector ~ '._domainkey.' ~ domain_item ~ './TXT').replace('\" \"', '') }}" # noqa no-tabs we need tabs in this content
- name: "Set up the {{ dkim_selector }}._domainkey.{{ domain_item }} TXT record" # noqa name[template] we need to be informative, even if we deviate from the standards
ansible.builtin.import_tasks: add_dns_record.yml
ansible.builtin.import_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{{ domain_item }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: "Set up ACME challenge TXT records for {{ challenge_item.key }}" # noqa name[template] we need to be informative, even if we deviate from the standards
ansible.builtin.import_tasks: add_dns_record.yml
ansible.builtin.import_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{{ challenge_item.key | replace('*.', '') }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/httpd.yml → tasks/httpd/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- poweradmin
- wireguard
- webdav
ansible.builtin.include_tasks: firewall.yml
ansible.builtin.include_tasks: security/firewall.yml
vars:
port: "{{ item }}" # noqa var-naming[no-reserved] we refer to a port here, so I call it a port
loop:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tasks/kolab.yml → tasks/kolab/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
tags:
- users
- name: Set up user mail aliases
ansible.builtin.include_tasks: user_mail_alias.yml
ansible.builtin.include_tasks: mail/user_mail_alias.yml
loop: "{{ users }}"
loop_control:
loop_var: user
Expand Down Expand Up @@ -513,7 +513,7 @@
- name: Refresh the certificates
ansible.builtin.command: 'openssl rehash /etc/dirsrv/slapd-{{ mailserver_domain | split(".") | first }}'
- name: Configure LDAP
ansible.builtin.import_tasks: ldap.yml
ansible.builtin.import_tasks: ldap/main.yml
tags:
- ldap
- users
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions tasks/ldap.yml → tasks/ldap/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
- name: Extract user data from the OS
ansible.builtin.command: /var/tmp/extract_user_data_to_migrate.sh
- name: "Update LDAP entries: {{ user_data_item }}"
ansible.builtin.include_tasks: convert_user_to_ldif.yml
ansible.builtin.include_tasks: ldap/convert_user_to_ldif.yml
loop: "{{ users }}"
loop_control:
loop_var: user_data_item
Expand All @@ -219,20 +219,20 @@
- users
block:
- name: "Add user to Kolab: {{ user.name }}"
ansible.builtin.include_tasks: add_kolab_user.yml
ansible.builtin.include_tasks: kolab/add_kolab_user.yml
loop: "{{ users }}"
loop_control:
loop_var: user
rescue:
- name: Authenticate against the Kolab API
ansible.builtin.include_tasks: kolab_auth.yml
ansible.builtin.include_tasks: kolab/kolab_auth.yml
- name: "Add user to Kolab: {{ user.name }}"
ansible.builtin.include_tasks: add_kolab_user.yml
ansible.builtin.include_tasks: kolab/add_kolab_user.yml
loop: "{{ users }}"
loop_control:
loop_var: user
- name: Set admin user group membership
ansible.builtin.include_tasks: add_admin_user_to_ldap_groups.yml
ansible.builtin.include_tasks: ldap/add_admin_user_to_ldap_groups.yml
loop:
- "cn=Directory Administrators,dc={{ mailserver_domain | split('.') | join(',dc=') }}"
- "cn=Accounting Managers,ou=groups,dc={{ mailserver_domain | split('.') | join(',dc=') }}"
Expand Down
4 changes: 2 additions & 2 deletions tasks/dkim.yml → tasks/mail/dkim.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# - name: Open firewall
# ansible.builtin.import_tasks: firewall.yml
# ansible.builtin.import_tasks: security/firewall.yml
# vars:
# port: 8891/tcp # noqa var-naming[no-reserved] we refer to a port here, so I call it a port
- name: Configure OpenDKIM
Expand Down Expand Up @@ -88,7 +88,7 @@
groups: opendkim
append: yes
- name: Check DKIM TXT records
ansible.builtin.include_tasks: propagate_dkim_txt_records.yml
ansible.builtin.include_tasks: dns/propagate_dkim_txt_records.yml
vars:
current_domain: "{{ item }}"
loop: "{{ [mailserver_domain] + custom_domains }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/dmarc.yml → tasks/mail/dmarc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- { key: "IgnoreMailFrom", value: "{{ undeliverable_exceptions | join(',') }}", comment: false }
notify: Restart opendmarc
- name: Set up DMARC TXT records
ansible.builtin.include_tasks: add_dns_record.yml
ansible.builtin.include_tasks: dns/add_dns_record.yml
vars:
record:
zone: "{{ item }}"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions tasks/postfix.yml → tasks/mail/postfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
system: yes
uid: 2000
- name: Open firewall
ansible.builtin.include_tasks: firewall.yml
ansible.builtin.include_tasks: security/firewall.yml
vars:
port: "{{ item }}" # noqa var-naming[no-reserved] we refer to a port here, so I call it a port
loop:
Expand All @@ -34,7 +34,7 @@
register: apply_new_aliases
changed_when: apply_new_aliases.rc == 0
- name: Set up automatic restart of services
ansible.builtin.import_tasks: autorestart.yml
ansible.builtin.import_tasks: systemd/autorestart.yml
vars:
service: postfix
# - name: Deploy Postfix master config
Expand Down Expand Up @@ -66,10 +66,10 @@
- name: Configure Postfix main.cf
tags:
- users
community.general.ini_file:
ansible.builtin.lineinfile:
regexp: "^{{ item.key }} = "
path: /etc/postfix/main.cf
option: "{{ item.key }}"
value: "{{ item.value }}"
line: "{{ item.key }} = {{ item.value }}"
backup: true
mode: u=rw,og=r
owner: root
Expand Down
4 changes: 2 additions & 2 deletions tasks/postfixadmin.yml → tasks/mail/postfixadmin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
setype: httpd_sys_rw_content_t
recurse: yes
- name: Create postfixadmin DB schema
ansible.builtin.import_tasks: create_mariadb_schema.yml
ansible.builtin.import_tasks: mariadb/create_mariadb_schema.yml
vars:
mariadb_database: postfixadmin
mariadb_state: "{{ ('import' if reset == 'yes') | default('present') }}"
Expand All @@ -37,7 +37,7 @@
login_password: "{{ mysql_root_password }}"
no_log: yes
- name: Fill postfixadmin DB with data
ansible.builtin.import_tasks: fill_mariadb_data.yml
ansible.builtin.import_tasks: mariadb/fill_mariadb_data.yml
vars:
mariadb_database:
db: postfixadmin
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5b51577

Please sign in to comment.