From 827344b6f1bfcc074ea7bbd5f19fde20fe9b6194 Mon Sep 17 00:00:00 2001 From: Fredrik Larsson Date: Wed, 17 Aug 2022 22:56:21 +0200 Subject: [PATCH 1/5] Use FQCN for builtin actions Fixes all ansible-lint errors. --- handlers/main.yml | 2 +- molecule/default/converge.yml | 2 +- tasks/acl.yml | 4 ++-- tasks/certificates.yml | 6 +++--- tasks/configuration.yml | 4 ++-- tasks/install.yml | 8 ++++---- tasks/letsencrypt.yml | 6 +++--- tasks/main.yml | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index ce489a5e..a1f6f4c0 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ # handlers file --- - name: restart haproxy - service: + ansible.builtin.service: name: haproxy state: "{{ haproxy_restart_handler_state }}" when: service_default_state | default('started') == 'started' diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 73043c48..8596f093 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,6 +4,6 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" roles: - ../../../ diff --git a/tasks/acl.yml b/tasks/acl.yml index 6da70552..2b4ce0c3 100644 --- a/tasks/acl.yml +++ b/tasks/acl.yml @@ -1,7 +1,7 @@ # tasks file --- - name: acl | create directories - file: + ansible.builtin.file: path: "{{ item.dest | dirname }}" state: directory owner: "{{ item.owner | default('root') }}" @@ -12,7 +12,7 @@ - haproxy-acl-create-directories - name: acl | update files - template: + ansible.builtin.template: src: etc/haproxy/acl.j2 dest: "{{ item.dest }}" owner: "{{ item.owner | default('root') }}" diff --git a/tasks/certificates.yml b/tasks/certificates.yml index d91d65c9..ef66b80b 100644 --- a/tasks/certificates.yml +++ b/tasks/certificates.yml @@ -1,7 +1,7 @@ # tasks file --- - name: certificates | create directories - file: + ansible.builtin.file: path: "{{ item.dest | dirname }}" state: directory owner: "{{ item.owner | default('root') }}" @@ -13,7 +13,7 @@ - haproxy-certificates-create-directories - name: certificates | copy files - copy: + ansible.builtin.copy: src: "{{ item.src }}" dest: "{{ item.dest }}" owner: "{{ item.owner | default('root') }}" @@ -26,7 +26,7 @@ - haproxy-certificates-copy-files - name: certificates | remove files - file: + ansible.builtin.file: path: "{{ item.dest }}" state: absent with_items: "{{ haproxy_ssl_map }}" diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 1888a91c..2d7c692f 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -1,7 +1,7 @@ # tasks file --- - name: configuration | warn or fail - fail: + ansible.builtin.fail: msg: "haproxy_global_nbproc is deprecated" ignore_errors: "{{ haproxy_version is version('2.5', '<') }}" when: @@ -11,7 +11,7 @@ - haproxy-configuration-warn-or-fail - name: configuration | update file - template: + ansible.builtin.template: src: "{{ haproxy_conf_template }}" dest: /etc/haproxy/haproxy.cfg owner: root diff --git a/tasks/install.yml b/tasks/install.yml index f63eb295..7bba6177 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,7 +1,7 @@ # tasks file --- - name: install | dependencies (pre) - apt: + ansible.builtin.apt: name: "{{ haproxy_dependencies_pre }}" state: "{{ apt_install_state | default('latest') }}" update_cache: true @@ -10,7 +10,7 @@ - haproxy-repository-install-dependencies - name: install | add repository from PPA and install its signing key - apt_repository: + ansible.builtin.apt_repository: repo: "{{ haproxy_ppa }}" update_cache: true when: haproxy_use_ppa | bool @@ -18,7 +18,7 @@ - haproxy-install-add-repository - name: install | dependencies - apt: + ansible.builtin.apt: name: "{{ item.name }}" state: "{{ item.state }}" with_items: "{{ haproxy_dependencies }}" @@ -26,7 +26,7 @@ - haproxy-install-dependencies - name: install | additional - apt: + ansible.builtin.apt: name: "{{ haproxy_install }}" state: "{{ apt_install_state | default('latest') }}" tags: diff --git a/tasks/letsencrypt.yml b/tasks/letsencrypt.yml index e0a04a28..f5bcbcdc 100644 --- a/tasks/letsencrypt.yml +++ b/tasks/letsencrypt.yml @@ -1,7 +1,7 @@ # tasks file --- - name: letsencrypt | copy SSL deploy script - template: + ansible.builtin.template: src: "{{ haproxy_letsencrypt_ssl_deploy_template }}" dest: "{{ haproxy_letsencrypt_ssl_deploy }}" owner: root @@ -11,7 +11,7 @@ - haproxy-letsencrypt-ssl-deploy - name: letsencrypt | copy OCSP deploy script - template: + ansible.builtin.template: src: "{{ haproxy_letsencrypt_ocsp_deploy_template }}" dest: "{{ haproxy_letsencrypt_ocsp_deploy }}" owner: root @@ -21,7 +21,7 @@ - haproxy-letsencrypt-ocsp-deploy - name: letsencrypt | configure (cron) job for OCSP deploy - cron: + ansible.builtin.cron: name: haproxy-letsencrypt-ocsp-deploy job: "{{ haproxy_letsencrypt_ocsp_deploy }}" state: "{{ haproxy_letsencrypt_ocsp_deploy_job.state | default('absent') }}" diff --git a/tasks/main.yml b/tasks/main.yml index 0b3fea42..a61a985e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ # tasks file --- - name: check version support - fail: + ansible.builtin.fail: msg: "HAProxy version {{ haproxy_version }} is not supported" when: haproxy_version | string not in haproxy_versions_supported tags: @@ -40,7 +40,7 @@ - haproxy-letsencrypt - name: start and enable service - service: + ansible.builtin.service: name: haproxy state: "{{ service_default_state | default('started') }}" enabled: "{{ service_default_enabled | default(true) | bool }}" From b49751788b43242160612cd2c22a0dfa1f21db7a Mon Sep 17 00:00:00 2001 From: Fredrik Larsson Date: Thu, 18 Aug 2022 19:14:48 +0200 Subject: [PATCH 2/5] Adapt Molecule version to its supported Ansible version * Molecule 3.0.8 is the last release supporting Ansible 2.9 * Technically Molecule 3.4.1 is the last version supporting Ansible 2.10, but Molecule 3.2.4 is the last version that actually works. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e41277fe..7f81be15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,8 +44,10 @@ jobs: include: - distro: ubuntu1604 ansible-version: '>=2.9, <2.10' + molecule_version: "==3.0.8" - distro: ubuntu1604 ansible-version: '>=2.10, <2.11' + molecule_version: "==3.2.4" - distro: ubuntu1604 - distro: ubuntu1804 - distro: ubuntu2004 @@ -62,7 +64,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[docker]${{ matrix.molecule_version }}' docker - name: Run Molecule tests run: | From 0771ff4d76be688a47e929aa2a46fa7f9a5068b4 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Sep 2022 16:50:45 +0200 Subject: [PATCH 3/5] Consistency changes --- .github/workflows/ci.yml | 10 ++++------ Dockerfile | 13 ++++++++----- meta/main.yml | 5 ++--- molecule/default/collections.yml | 6 ++++++ tasks/main.yml | 12 ++++++------ tests/test.yml | 2 +- tests/vagrant.yml | 2 +- 7 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 molecule/default/collections.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f81be15..628fecdd 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: | @@ -42,12 +44,8 @@ jobs: fail-fast: false matrix: include: - - distro: ubuntu1604 - ansible-version: '>=2.9, <2.10' - molecule_version: "==3.0.8" - distro: ubuntu1604 ansible-version: '>=2.10, <2.11' - molecule_version: "==3.2.4" - distro: ubuntu1604 - distro: ubuntu1804 - distro: ubuntu2004 @@ -64,7 +62,7 @@ jobs: python-version: '3.x' - name: Install test dependencies - run: pip install 'ansible${{ matrix.ansible-version }}' 'molecule[docker]${{ matrix.molecule_version }}' docker + run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker - name: Run Molecule tests run: | diff --git a/Dockerfile b/Dockerfile index b1792787..6ebe0c46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 MAINTAINER Mischa ter Smitten +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 + # python RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal python3-dev curl && \ apt-get clean -RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python - +RUN curl -sL https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 - RUN rm -rf $HOME/.cache # ansible -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \ +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \ apt-get clean -RUN pip install ansible==2.9.15 +RUN pip3 install ansible==2.10.7 RUN rm -rf $HOME/.cache # provision diff --git a/meta/main.yml b/meta/main.yml index afb3e5b9..a8fe8a7d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,13 +1,12 @@ # meta file --- galaxy_info: - namespace: oefenweb + author: oefenweb role_name: haproxy - author: Mischa ter Smitten company: Oefenweb.nl B.V. description: Set up the latest version of HAProxy in Ubuntu systems license: MIT - min_ansible_version: 2.9.0 + min_ansible_version: 2.10.0 platforms: - name: Ubuntu versions: diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml new file mode 100644 index 00000000..c3d7e2a1 --- /dev/null +++ b/molecule/default/collections.yml @@ -0,0 +1,6 @@ +--- +collections: + - name: community.docker + version: '>=1.2.0,<2' + - name: community.general + version: '>=2,<3' diff --git a/tasks/main.yml b/tasks/main.yml index a61a985e..8cacf52f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,38 +9,38 @@ - haproxy - haproxy-check-version-support -- import_tasks: install.yml +- ansible.builtin.import_tasks: install.yml tags: - configuration - haproxy - haproxy-install -- import_tasks: certificates.yml +- ansible.builtin.import_tasks: certificates.yml tags: - configuration - haproxy - haproxy-certificates -- import_tasks: acl.yml +- ansible.builtin.import_tasks: acl.yml tags: - configuration - haproxy - haproxy-acl -- import_tasks: configuration.yml +- ansible.builtin.import_tasks: configuration.yml tags: - configuration - haproxy - haproxy-configuration -- import_tasks: letsencrypt.yml +- ansible.builtin.import_tasks: letsencrypt.yml tags: - configuration - haproxy - haproxy-letsencrypt - name: start and enable service - ansible.builtin.service: + ansible.builtin.ansible.builtin.service: name: haproxy state: "{{ service_default_state | default('started') }}" enabled: "{{ service_default_enabled | default(true) | bool }}" diff --git a/tests/test.yml b/tests/test.yml index c2fbb9f2..8d7cd5f3 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,6 +5,6 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" roles: - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml index 38089226..851ce223 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,6 +5,6 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" roles: - ../../ From dce9841191feb6352bd7affcdf9a6f821cba32a7 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Sep 2022 16:59:50 +0200 Subject: [PATCH 4/5] Add missing file --- requirements.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.yml diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 00000000..3d5f1cd3 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,3 @@ +# requirements file +--- +collections: [] From d385bdd93b826e238047191a0aff2fe39ec1660c Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 2 Sep 2022 17:01:37 +0200 Subject: [PATCH 5/5] Cs fixes --- .ansible-lint | 4 ++-- tasks/configuration.yml | 2 +- tasks/main.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 6b9b3910..fd56a0ea 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,4 +1,4 @@ --- warn_list: - - '106' - - ignore-errors + - role-name + - name diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 2d7c692f..007ceda7 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -1,6 +1,6 @@ # tasks file --- -- name: configuration | warn or fail +- name: configuration | warn or fail # noqa: ignore-errors ansible.builtin.fail: msg: "haproxy_global_nbproc is deprecated" ignore_errors: "{{ haproxy_version is version('2.5', '<') }}" diff --git a/tasks/main.yml b/tasks/main.yml index 8cacf52f..e8accc0a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -40,7 +40,7 @@ - haproxy-letsencrypt - name: start and enable service - ansible.builtin.ansible.builtin.service: + ansible.builtin.service: name: haproxy state: "{{ service_default_state | default('started') }}" enabled: "{{ service_default_enabled | default(true) | bool }}"