From fbe074f41775a8eca50d7cf93e9ccdd7524d14b8 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 19 Aug 2024 16:06:10 +0200 Subject: [PATCH] refctor: rework ci to ue ansible-lint and fix molecule --- .later.yml | 15 --------------- .woodpecker/docs.yaml | 10 +++++----- .woodpecker/lint.yaml | 6 +++--- .woodpecker/test.yaml | 2 +- .yamllint | 20 ++++++++++++++++++++ meta/main.yml | 3 --- molecule/default/molecule.yml | 6 +++--- molecule/requirements.yml | 4 ---- requirements.yml | 7 +++++++ tasks/config_default.yml | 2 ++ tasks/config_univention.yml | 3 ++- tasks/main.yml | 17 +++++++++++++---- tasks/post_tasks.yml | 7 ------- 13 files changed, 56 insertions(+), 46 deletions(-) delete mode 100644 .later.yml create mode 100644 .yamllint delete mode 100644 molecule/requirements.yml create mode 100644 requirements.yml delete mode 100644 tasks/post_tasks.yml diff --git a/.later.yml b/.later.yml deleted file mode 100644 index 2703cb9..0000000 --- a/.later.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -ansible: - custom_modules: - - iptables_raw - - openssl_pkcs12 - - proxmox_kvm - - ucr - - corenetworks_dns - - corenetworks_token - -rules: - exclude_files: - - "LICENSE*" - - "**/*.md" - - "**/*.ini" diff --git a/.woodpecker/docs.yaml b/.woodpecker/docs.yaml index f053ca8..857444b 100644 --- a/.woodpecker/docs.yaml +++ b/.woodpecker/docs.yaml @@ -9,11 +9,11 @@ steps: - name: generate image: quay.io/thegeeklab/ansible-doctor environment: - ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/ - ANSIBLE_DOCTOR_FORCE_OVERWRITE: "true" - ANSIBLE_DOCTOR_LOG_LEVEL: INFO - ANSIBLE_DOCTOR_ROLE_NAME: ${CI_REPO_NAME} - ANSIBLE_DOCTOR_TEMPLATE: readme + ANSIBLE_DOCTOR_EXCLUDE_FILES: "['molecule/']" + ANSIBLE_DOCTOR_RENDERER__FORCE_OVERWRITE: "true" + ANSIBLE_DOCTOR_LOGGING__LEVEL: info + ANSIBLE_DOCTOR_ROLE__NAME: ${CI_REPO_NAME} + ANSIBLE_DOCTOR_TEMPLATE__NAME: readme - name: format image: quay.io/thegeeklab/alpine-tools diff --git a/.woodpecker/lint.yaml b/.woodpecker/lint.yaml index 36b1ec8..c48a8e4 100644 --- a/.woodpecker/lint.yaml +++ b/.woodpecker/lint.yaml @@ -6,10 +6,10 @@ when: - ${CI_REPO_DEFAULT_BRANCH} steps: - - name: ansible-later - image: quay.io/thegeeklab/ansible-later:4 + - name: ansible-lint + image: quay.io/thegeeklab/ansible-dev-tools:1 commands: - - ansible-later + - ansible-lint environment: FORCE_COLOR: "1" diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index 256ad91..661dc8b 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -7,7 +7,7 @@ when: variables: - &molecule_base - image: quay.io/thegeeklab/molecule:6 + image: quay.io/thegeeklab/ansible-dev-tools:1 group: molecule environment: PY_COLORS: "1" diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..df1d39e --- /dev/null +++ b/.yamllint @@ -0,0 +1,20 @@ +--- +extends: default + +rules: + truthy: + allowed-values: ["True", "False"] + comments: + min-spaces-from-content: 1 + comments-indentation: False + line-length: disable + braces: + min-spaces-inside: 0 + max-spaces-inside: 1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + indentation: enable + octal-values: + forbid-implicit-octal: True + forbid-explicit-octal: True diff --git a/meta/main.yml b/meta/main.yml index 22504fe..b59b9fa 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -22,6 +22,3 @@ galaxy_info: - relay - mail dependencies: [] -collections: - - xoxys.general - - community.general diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 948e268..44ae59a 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,11 +4,11 @@ driver: dependency: name: galaxy options: - role-file: molecule/requirements.yml - requirements-file: molecule/requirements.yml + role-file: requirements.yml + requirements-file: requirements.yml platforms: - name: "rocky9-postfix-relay" - server_type: "CX22" + server_type: "cx22" image: "rocky-9" provisioner: name: ansible diff --git a/molecule/requirements.yml b/molecule/requirements.yml deleted file mode 100644 index 5b676bf..0000000 --- a/molecule/requirements.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -collections: [] - -roles: [] diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..5454df6 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: + - name: https://gitea.rknet.org/ansible/xoxys.general + type: git + version: main + +roles: [] diff --git a/tasks/config_default.yml b/tasks/config_default.yml index 8224ccf..a3fd7ce 100644 --- a/tasks/config_default.yml +++ b/tasks/config_default.yml @@ -24,6 +24,7 @@ - name: Create sasl_passwd.db ansible.builtin.command: /usr/sbin/postmap hash:/etc/postfix/sasl_passwd + changed_when: False when: not __sasldb.stat.exists or __sasl_result.changed notify: __postfix_restart @@ -51,5 +52,6 @@ - name: Hash sender_canoncial ansible.builtin.command: "/usr/sbin/postmap hash:/etc/postfix/sender_canonical" + changed_when: False when: not __senderdb.stat.exists or __sender_result.changed notify: __postfix_restart diff --git a/tasks/config_univention.yml b/tasks/config_univention.yml index 32f4eb9..3bf7ed0 100644 --- a/tasks/config_univention.yml +++ b/tasks/config_univention.yml @@ -1,6 +1,6 @@ --- - name: Set postfix settings to registry - ucr: + xoxys.general.ucr: path: "{{ item.path }}" value: "{{ item.value }}" state: "{{ item.state | default('present') }}" @@ -22,6 +22,7 @@ - name: Create smtp_auth.db ansible.builtin.command: /usr/sbin/postmap hash:/etc/postfix/smtp_auth + changed_when: False when: not __authdb.stat.exists or __auth_result.changed notify: __postfix_restart diff --git a/tasks/main.yml b/tasks/main.yml index 5d2cbf4..357773d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.include_vars: "{{ var_files }}" +- name: Include OS specific vars + ansible.builtin.include_vars: "{{ var_files }}" vars: var_files: "{{ lookup('first_found', params, errors='ignore') }}" params: @@ -10,8 +11,10 @@ paths: - "vars" when: var_files -- ansible.builtin.include_tasks: install.yml -- ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}" +- name: Install postfix + ansible.builtin.include_tasks: install.yml +- name: Configure postfix + ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}" vars: params: files: @@ -20,4 +23,10 @@ - "config_default.yml" paths: - "tasks" -- ansible.builtin.include_tasks: post_tasks.yml + +- name: Ensure postfix service is up and running + ansible.builtin.service: + name: "postfix" + state: started + daemon_reload: True + enabled: True diff --git a/tasks/post_tasks.yml b/tasks/post_tasks.yml deleted file mode 100644 index 851fe46..0000000 --- a/tasks/post_tasks.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Ensure postfix service is up and running - ansible.builtin.service: - name: "postfix" - state: started - daemon_reload: yes - enabled: yes