From 8d8f055ceedad04e49b8f6aab80884a4832c2916 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 28 Oct 2023 16:47:54 +0200 Subject: [PATCH] improve linting and adding requirements --- README.md | 10 ++++++++-- requirements.yml | 4 ++++ tasks/main.yml | 15 ++++++++++----- tasks/versioncheck.yml | 15 +++++++-------- vars/main.yml | 2 +- 5 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 requirements.yml diff --git a/README.md b/README.md index ddf4ae0..4d400da 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Ansible Galaxy](https://ansible.l3d.space/svg/l3d.ntp.svg)](https://galaxy.ansible.com/l3d/ntp) +[![Ansible Galaxy](https://ansible.l3d.space/svg/l3d.ntp.svg)](https://galaxy.ansible.com/ui/standalone/roles/l3d/ntp/) [![BSD-3 Clause](https://ansible.l3d.space/svg/l3d.ntp_license.svg)](LICENSE) [![Maintainance](https://ansible.l3d.space/svg/l3d.ntp_maintainance.svg)](https://ansible.l3d.space/#l3d.ntp) @@ -74,9 +74,15 @@ git clone https://github.com/roles-ansible/ansible_role_ntp.git l3d.ntp ## Resources - [ntp on ubuntu](https://doc.ubuntu-fr.org/ntp) +## Requirements +The ``community.general`` collection is required for some parts of this ansible role. +You can install it with this command: +```bash +ansible-galaxy collection install -r requirements.yml --upgrade +``` + ## Author Information + This role was created in 2018 by diodonfrost. diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..a5a1e10 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: 'community.general' + version: ">=7.5.0,<=8.0.0" diff --git a/tasks/main.yml b/tasks/main.yml index dae11ac..0df7650 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,17 +1,22 @@ --- - name: Optionally run versionscheck if enabled - ansible.builtin.include_tasks: versioncheck.yml + ansible.builtin.include_tasks: + file: versioncheck.yml when: submodules_versioncheck | bool - name: Include OS specific variables. - ansible.builtin.include_vars: "{{ lookup('first_found', ntp__vars) }}" + ansible.builtin.include_vars: + file: "{{ lookup('first_found', ntp__vars) }}" - name: Install ntp - ansible.builtin.include_tasks: "{{ lookup('first_found', ntp__install) }}" + ansible.builtin.include_tasks: + file: "{{ lookup('first_found', ntp__install) }}" - name: Configure ntp - ansible.builtin.include_tasks: config.yml + ansible.builtin.include_tasks: + file: config.yml - name: Optionally set NTP Timezone - ansible.builtin.include_tasks: set_time_zone.yml + ansible.builtin.include_tasks: + file: set_time_zone.yml when: ntp_set_time_zone | bool diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 1af569d..e660e3e 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -13,18 +13,17 @@ - name: Check playbook version become: true ansible.builtin.slurp: - src: "/etc/.ansible-version/{{ ntp__playbook_version_path }}" - register: ntp__playbook_version + src: "/etc/.ansible-version/{{ playbook_version_path }}" + register: playbook_version when: submodules_versioncheck | bool - ignore_errors: true failed_when: false -- name: Print remote role version +- name: Print remote role version # noqa: H500 ansible.builtin.debug: - msg: "Remote role version: {{ ntp__playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" when: submodules_versioncheck | bool -- name: Print locale role version +- name: Print locale role version # noqa: H500 ansible.builtin.debug: msg: "Local role version: '{{ playbook_version_number | string }}'." when: submodules_versioncheck | bool @@ -33,13 +32,13 @@ ansible.builtin.fail: msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" when: - - ntp__playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool - name: Write new version to remote disk become: true ansible.builtin.copy: content: "{{ playbook_version_number }}" - dest: "/etc/.ansible-version/{{ ntp__playbook_version_path }}" + dest: "/etc/.ansible-version/{{ playbook_version_path }}" mode: '0644' when: submodules_versioncheck | bool tags: skip_ansible_lint_template-instead-of-copy diff --git a/vars/main.yml b/vars/main.yml index 4ef79c9..0f0ac6d 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,5 +1,5 @@ --- -playbook_version_number: 2057 +playbook_version_number: 2058 ntp__playbook_version_path: 'role-ntp_chaos-bodensee_github.com.version' ntp__vars: