From 0e7aed969f22d82e60795f71fecf45cf6c2a614c Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Wed, 30 Aug 2023 12:38:52 +0200 Subject: [PATCH 1/2] WIP --- .ansible-lint | 1 + .github/workflows/ci.yml | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 7e0172a..b04781e 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,4 +1,5 @@ --- warn_list: - role-name + - name[play] - name[casing] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7d526c..7e2bc34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ jobs: python-version: '3.x' - name: Install test dependencies - run: pip install ansible-lint[community,yamllint] + run: | + pip install ansible-lint + ansible-galaxy install -r requirements.yml - name: Lint code run: | @@ -43,11 +45,8 @@ jobs: matrix: include: - distro: debian8 - ansible-version: '<2.10' - distro: debian9 - distro: debian10 - - distro: ubuntu1604 - ansible-version: '>=2.9, <2.10' - distro: ubuntu1604 ansible-version: '>=2.10, <2.11' - distro: ubuntu1604 @@ -66,14 +65,14 @@ jobs: python-version: '3.x' - name: Install test dependencies - run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker + run: pip install 'ansible${{ matrix.ansible-version }}' molecule-plugins[docker] docker - name: Run Molecule tests run: | molecule test env: ANSIBLE_FORCE_COLOR: '1' - ANSIBLE_VERBOSITY: '3' + ANSIBLE_VERBOSITY: '2' MOLECULE_DEBUG: '1' MOLECULE_DISTRO: "${{ matrix.distro }}" PY_COLORS: '1' From 5638836f0487facbd01a3380331de4ec7ac6162c Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Wed, 30 Aug 2023 12:41:13 +0200 Subject: [PATCH 2/2] WIP --- handlers/main.yml | 2 +- molecule/default/prepare.yml | 4 ++-- tasks/main.yml | 10 +++++----- tests/tasks/pre.yml | 2 +- tests/test.yml | 4 ++-- tests/vagrant.yml | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 0dcd701..5054bd9 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ # handlers file --- - name: restart ssh - service: + ansible.builtin.service: name: ssh state: restarted when: service_default_state | default('started') == 'started' diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index bb63e11..4e9fc84 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -4,6 +4,6 @@ become: true tasks: - name: include vars - include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" - name: include tasks - include: "{{ playbook_dir }}/../../tests/tasks/pre.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/../../tests/tasks/pre.yml" diff --git a/tasks/main.yml b/tasks/main.yml index 724a1c9..4664079 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ # tasks file --- - name: install dependencies - apt: + ansible.builtin.apt: name: "{{ ssh_server_dependencies }}" state: "{{ apt_install_state | default('latest') }}" update_cache: true @@ -12,7 +12,7 @@ - ssh-server-dependencies - name: install - apt: + ansible.builtin.apt: name: "{{ ssh_server_install }}" state: "{{ apt_install_state | default('latest') }}" tags: @@ -21,7 +21,7 @@ - ssh-server-install - name: check host keys - command: > + ansible.builtin.command: > ssh-keygen -A args: creates: "{{ item }}" @@ -35,7 +35,7 @@ - ssh-server-check-host-keys - name: update configuration file - template: + ansible.builtin.template: src: etc/ssh/sshd_config.j2 dest: /etc/ssh/sshd_config owner: root @@ -49,7 +49,7 @@ - ssh-server-configuration - name: start and enable service - service: + ansible.builtin.service: name: ssh state: "{{ service_default_state | default('started') }}" enabled: "{{ service_default_enabled | default(true) | bool }}" diff --git a/tests/tasks/pre.yml b/tests/tasks/pre.yml index 6cb0d48..84edd27 100644 --- a/tests/tasks/pre.yml +++ b/tests/tasks/pre.yml @@ -2,7 +2,7 @@ --- # To prevent: Missing privilege separation directory - name: create (needed) directory - file: + ansible.builtin.file: path: /run/sshd state: directory owner: root diff --git a/tests/test.yml b/tests/test.yml index d3837dc..69b9404 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,8 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" - name: include tasks - include: "{{ playbook_dir }}/tasks/pre.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml index dce3560..0dff732 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,8 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" - name: include tasks - include: "{{ playbook_dir }}/tasks/pre.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../