diff --git a/.ansible-lint b/.ansible-lint index 3a9a0df..b04781e 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,6 +1,5 @@ --- warn_list: - role-name + - name[play] - name[casing] - - '306' - - '403' 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: | diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 73043c4..8596f09 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/molecule/default/verify.yml b/molecule/default/verify.yml index edfe900..3f1ea7a 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -4,4 +4,4 @@ become: true tasks: - name: include tasks - include: "{{ playbook_dir }}/../../tests/tasks/post.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/../../tests/tasks/post.yml" diff --git a/requirements.yml b/requirements.yml index 3d5f1cd..6333a29 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,3 +1,4 @@ # requirements file --- -collections: [] +collections: + - name: community.general diff --git a/tasks/main.yml b/tasks/main.yml index d7ff815..5e2eb0d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ # tasks file --- - name: install dependencies - apt: + ansible.builtin.apt: name: "{{ nodejs_dependencies }}" state: "{{ apt_install_state | default('latest') }}" update_cache: true @@ -13,7 +13,7 @@ - nodejs-install-dependencies - name: install additional - apt: + ansible.builtin.apt: name: "{{ nodejs_install }}" state: "{{ apt_install_state | default('latest') }}" tags: @@ -22,8 +22,8 @@ - nodejs-install - nodejs-install-additional -- name: add repository and install its signing key # noqa command-instead-of-module - shell: > +- name: add repository and install its signing key # noqa command-instead-of-module risky-shell-pipe + ansible.builtin.shell: > curl -sL https://deb.nodesource.com/setup_{{ nodejs_version_map[nodejs_version] }} | bash - args: creates: /etc/apt/sources.list.d/nodesource.list @@ -34,7 +34,7 @@ - nodejs-install-add-repository - name: install - apt: + ansible.builtin.apt: name: "{{ 'nodejs' if 'nodejs' in nodejs_version else 'iojs' }}" state: "{{ apt_install_state | default('latest') }}" tags: @@ -44,13 +44,24 @@ - nodejs-install-install - name: install node.js packages (globally) - npm: - name: "{{ item.name }}" - version: "{{ item.version | default('latest') }}" - global: true - with_items: "{{ nodejs_npm_packages }}" tags: - configuration - nodejs - nodejs-npm - nodejs-npm-install + block: + - name: install node.js packages (specific version) + community.general.npm: + name: "{{ item.name }}" + version: "{{ item.version }}" + global: true + with_items: "{{ nodejs_npm_packages }}" + when: "item.version | default('latest') != 'latest'" + + - name: install node.js packages (latest version) + community.general.npm: + name: "{{ item.name }}" + state: "{{ item.version | default('latest') }}" + global: true + with_items: "{{ nodejs_npm_packages }}" + when: "item.version | default('latest') == 'latest'" diff --git a/tests/tasks/post.yml b/tests/tasks/post.yml index 7431274..31c8328 100644 --- a/tests/tasks/post.yml +++ b/tests/tasks/post.yml @@ -1,15 +1,15 @@ # post test file --- -- name: install dependencies - apt: +- name: install dependencies # noqa package-latest + ansible.builtin.apt: name: - curl state: latest update_cache: true cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" -- name: test installation # noqa command-instead-of-module - command: > +- name: test installation # noqa command-instead-of-module risky-shell-pipe + ansible.builtin.command: > echo 'console.log("PING".replace("I", "O"));' | nodejs | grep -q 'PONG' @@ -21,7 +21,7 @@ - skip_ansible_lint - name: run tests - command: > + ansible.builtin.command: > {{ item }} changed_when: false with_items: diff --git a/tests/test.yml b/tests/test.yml index 0f87724..106f9ee 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,11 +5,11 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" roles: - ../../ post_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/post.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/post.yml" diff --git a/tests/vagrant.yml b/tests/vagrant.yml index ca79e3d..f914693 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,11 +5,11 @@ become: true pre_tasks: - name: include vars - include_vars: "{{ playbook_dir }}/vars/main.yml" + ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" roles: - ../../ post_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/post.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/post.yml"