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/.github/workflows/ci.yml b/.github/workflows/ci.yml index e41277fe..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,8 +44,6 @@ jobs: fail-fast: false matrix: include: - - distro: ubuntu1604 - ansible-version: '>=2.9, <2.10' - distro: ubuntu1604 ansible-version: '>=2.10, <2.11' - distro: ubuntu1604 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/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/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/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/requirements.yml b/requirements.yml new file mode 100644 index 00000000..3d5f1cd3 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,3 @@ +# requirements file +--- +collections: [] 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..007ceda7 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -1,7 +1,7 @@ # tasks file --- -- name: configuration | warn or fail - 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', '<') }}" 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..e8accc0a 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: @@ -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 - service: + 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: - ../../