From 12bdd5deb0b21f6cd99840088e442b1de470f932 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Jun 2023 14:27:55 +0200 Subject: [PATCH 1/4] WIP --- .ansible-lint | 1 + .github/workflows/ci.yml | 9 ++++----- 2 files changed, 5 insertions(+), 5 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 292e437..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,7 +65,7 @@ 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: | From c540ef9cc8e60b83e0b6d099c4967e8f6f5828e1 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Jun 2023 14:30:33 +0200 Subject: [PATCH 2/4] WIP --- handlers/main.yml | 4 ++-- tasks/configure.yml | 17 ++++++++--------- tasks/install.yml | 4 ++-- tasks/main.yml | 6 ++++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index fbb0a7f..39b6861 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,12 +1,12 @@ # handlers file --- - name: apply netplan config - command: > + ansible.builtin.command: > netplan apply listen: netplan apply config - name: generate netplan config - command: > + ansible.builtin.command: > netplan generate listen: netplan generate config notify: netplan apply config diff --git a/tasks/configure.yml b/tasks/configure.yml index 7a570e8..bedeb0e 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,15 +1,18 @@ # tasks file --- -- block: - +- name: configure + when: netplan_conf_purge | bool + tags: + - netplan-configure-purge + block: - name: configure | find existing - find: + ansible.builtin.find: paths: "{{ netplan_conf_path }}" patterns: '*.yaml,*.yml' register: _netplan_existing_files - name: configure | remove existing - file: + ansible.builtin.file: path: "{{ item['path'] }}" state: absent with_items: "{{ _netplan_existing_files['files'] }}" @@ -17,12 +20,8 @@ - item['path'] != netplan_conf_path + '/' + netplan_conf_file notify: netplan generate config - when: netplan_conf_purge | bool - tags: - - netplan-configure-purge - - name: configure | update - template: + ansible.builtin.template: src: etc/netplan/config.yaml.j2 dest: "{{ netplan_conf_path }}/{{ netplan_conf_file }}" mode: 0644 diff --git a/tasks/install.yml b/tasks/install.yml index 5fdb397..997c10d 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,7 +1,7 @@ # tasks file --- - name: install | dependencies - apt: + ansible.builtin.apt: name: "{{ netplan_dependencies }}" state: "{{ apt_install_state | default('latest') }}" update_cache: true @@ -10,7 +10,7 @@ - netplan-install-dependencies - name: install | additional - apt: + ansible.builtin.apt: name: "{{ netplan_install }}" state: "{{ apt_install_state | default('latest') }}" tags: diff --git a/tasks/main.yml b/tasks/main.yml index 4f8cc98..e58ee05 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,14 @@ # tasks file --- -- import_tasks: install.yml +- name: install + ansible.builtin.import_tasks: install.yml tags: - configuration - netplan - netplan-install -- import_tasks: configure.yml +- name: configure +- ansible.builtin.import_tasks: configure.yml tags: - configuration - netplan From 8d9d7b298ad4bbfe88db349add2b95eeb6443f49 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Jun 2023 14:35:35 +0200 Subject: [PATCH 3/4] Cs fix --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index e58ee05..2103437 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,7 +8,7 @@ - netplan-install - name: configure -- ansible.builtin.import_tasks: configure.yml + ansible.builtin.import_tasks: configure.yml tags: - configuration - netplan From 13eb49f66c72ee7311941042c130c4ce1d344b3f Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 5 Jun 2023 11:48:50 +0200 Subject: [PATCH 4/4] Cs fixes --- handlers/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 39b6861..e8cceae 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,11 +1,11 @@ # handlers file --- -- name: apply netplan config +- name: apply netplan config # noqa no-changed-when ansible.builtin.command: > netplan apply listen: netplan apply config -- name: generate netplan config +- name: generate netplan config # noqa no-changed-when ansible.builtin.command: > netplan generate listen: netplan generate config