From 1fbe49934e794bc5a12054ead6931e2c7b8fdc2f Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 21 Oct 2020 16:00:35 +0200 Subject: [PATCH 1/5] tests: Remove duplicate newlines --- tests/test_match.yml | 1 - tests/test_match_iterate.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/test_match.yml b/tests/test_match.yml index 1e5e5ab..f0aebb4 100644 --- a/tests/test_match.yml +++ b/tests/test_match.yml @@ -24,7 +24,6 @@ PasswordAuthentication: no PermitTunnel: yes - - name: Verify the options are correctly set block: - meta: flush_handlers diff --git a/tests/test_match_iterate.yml b/tests/test_match_iterate.yml index a1cedb7..12d3f66 100644 --- a/tests/test_match_iterate.yml +++ b/tests/test_match_iterate.yml @@ -22,7 +22,6 @@ PasswordAuthentication: no PermitTunnel: yes - - name: Verify the options are correctly set block: - meta: flush_handlers From 0ba1b77f9204532484939ca84e37956e10f9946b Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 21 Oct 2020 16:05:27 +0200 Subject: [PATCH 2/5] tests: Remove duplicate become (already specified on ansible-playbook commandline) --- tests/test_alternative_file.yml | 1 - tests/test_default.yml | 1 - tests/test_default_include.yml | 1 - tests/test_match.yml | 1 - tests/test_match_iterate.yml | 1 - tests/test_set_common.yml | 1 - tests/test_set_uncommon.yml | 1 - tests/test_sysconfig.yml | 1 - 8 files changed, 8 deletions(-) diff --git a/tests/test_alternative_file.yml b/tests/test_alternative_file.yml index ad45868..2e5529d 100644 --- a/tests/test_alternative_file.yml +++ b/tests/test_alternative_file.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure alternative sshd_config file include_role: diff --git a/tests/test_default.yml b/tests/test_default.yml index 3455971..dfb0f89 100644 --- a/tests/test_default.yml +++ b/tests/test_default.yml @@ -1,5 +1,4 @@ --- - hosts: all - become: true roles: - ansible-sshd diff --git a/tests/test_default_include.yml b/tests/test_default_include.yml index de17c23..d3d98d7 100644 --- a/tests/test_default_include.yml +++ b/tests/test_default_include.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: "Configure sshd" include_role: diff --git a/tests/test_match.yml b/tests/test_match.yml index f0aebb4..e409da6 100644 --- a/tests/test_match.yml +++ b/tests/test_match.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure sshd include_role: diff --git a/tests/test_match_iterate.yml b/tests/test_match_iterate.yml index 12d3f66..fc3496a 100644 --- a/tests/test_match_iterate.yml +++ b/tests/test_match_iterate.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure sshd include_role: diff --git a/tests/test_set_common.yml b/tests/test_set_common.yml index e2fd624..6483fb8 100644 --- a/tests/test_set_common.yml +++ b/tests/test_set_common.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure sshd include_role: diff --git a/tests/test_set_uncommon.yml b/tests/test_set_uncommon.yml index d3a55fc..13586f5 100644 --- a/tests/test_set_uncommon.yml +++ b/tests/test_set_uncommon.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure sshd with uncommon options, making sure it keeps running block: diff --git a/tests/test_sysconfig.yml b/tests/test_sysconfig.yml index 04732e4..75e6bd1 100644 --- a/tests/test_sysconfig.yml +++ b/tests/test_sysconfig.yml @@ -1,6 +1,5 @@ --- - hosts: all - become: true tasks: - name: Configure sshd include_role: From 7da7f8199f0656fc46b77f054749adce5f6e9ce8 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 21 Oct 2020 17:21:05 +0200 Subject: [PATCH 3/5] Rename test to tests --- .travis.yml | 18 +++++++++--------- ...ive_file.yml => tests_alternative_file.yml} | 0 tests/{test_default.yml => tests_default.yml} | 0 ...t_include.yml => tests_default_include.yml} | 0 tests/{test_match.yml => tests_match.yml} | 0 ...tch_iterate.yml => tests_match_iterate.yml} | 0 ...est_set_common.yml => tests_set_common.yml} | 0 ...set_uncommon.yml => tests_set_uncommon.yml} | 0 ...{test_sysconfig.yml => tests_sysconfig.yml} | 0 9 files changed, 9 insertions(+), 9 deletions(-) rename tests/{test_alternative_file.yml => tests_alternative_file.yml} (100%) rename tests/{test_default.yml => tests_default.yml} (100%) rename tests/{test_default_include.yml => tests_default_include.yml} (100%) rename tests/{test_match.yml => tests_match.yml} (100%) rename tests/{test_match_iterate.yml => tests_match_iterate.yml} (100%) rename tests/{test_set_common.yml => tests_set_common.yml} (100%) rename tests/{test_set_uncommon.yml => tests_set_uncommon.yml} (100%) rename tests/{test_sysconfig.yml => tests_sysconfig.yml} (100%) diff --git a/.travis.yml b/.travis.yml index 317e2f2..cd47544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,47 +15,47 @@ install: script: # Test 0: Check the roles syntax. - - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --syntax-check" + - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --syntax-check" # Test 1a: Run the role - - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become -v" + - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local --become -v" # Test 1b: Run the role through include - - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default_include.yml --connection=local --become -v" + - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default_include.yml --connection=local --become -v" # Test 2: Run the role/playbook again, checking to make sure it's idempotent. - > - ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become | grep -q 'changed=0.*failed=0' + ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local --become | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) # Test 3: Check we can set arbitrary configuration options - > - ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_set_common.yml --connection=local --become -v + ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_set_common.yml --connection=local --become -v && (echo 'Common variables test: pass' && exit 0) || (echo 'Common variables test: fail' && exit 1) # Test 4: Check if we set uncommon or unsupported configuration option, it will not fail hard - > - ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_set_uncommon.yml --connection=local --become -v + ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_set_uncommon.yml --connection=local --become -v && (echo 'Uncommon configuration test: pass' && exit 0) || (echo 'Uncommon configuration test: fail' && exit 1) # Test 5: Make sure we can modify other files, for example for inclusion # in the main sshd_config or second sshd service - > - ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_alternative_file.yml --connection=local --become -v + ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_alternative_file.yml --connection=local --become -v && (echo 'Alternative configuration file test: pass' && exit 0) || (echo 'Alternative configuration file test: fail' && exit 1) # Test 6: Test match blocks generators - > - ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_match.yml --connection=local --become -v + ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_match.yml --connection=local --become -v && (echo 'Match blocks test: pass' && exit 0) || (echo 'Match blocks test: fail' && exit 1) # Test 7: Test match blocks generators with iteration - > - ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_match_iterate.yml --connection=local --become -v + ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_match_iterate.yml --connection=local --become -v && (echo 'Match blocks with iteration test: pass' && exit 0) || (echo 'Match blocks with iteration test: fail' && exit 1) diff --git a/tests/test_alternative_file.yml b/tests/tests_alternative_file.yml similarity index 100% rename from tests/test_alternative_file.yml rename to tests/tests_alternative_file.yml diff --git a/tests/test_default.yml b/tests/tests_default.yml similarity index 100% rename from tests/test_default.yml rename to tests/tests_default.yml diff --git a/tests/test_default_include.yml b/tests/tests_default_include.yml similarity index 100% rename from tests/test_default_include.yml rename to tests/tests_default_include.yml diff --git a/tests/test_match.yml b/tests/tests_match.yml similarity index 100% rename from tests/test_match.yml rename to tests/tests_match.yml diff --git a/tests/test_match_iterate.yml b/tests/tests_match_iterate.yml similarity index 100% rename from tests/test_match_iterate.yml rename to tests/tests_match_iterate.yml diff --git a/tests/test_set_common.yml b/tests/tests_set_common.yml similarity index 100% rename from tests/test_set_common.yml rename to tests/tests_set_common.yml diff --git a/tests/test_set_uncommon.yml b/tests/tests_set_uncommon.yml similarity index 100% rename from tests/test_set_uncommon.yml rename to tests/tests_set_uncommon.yml diff --git a/tests/test_sysconfig.yml b/tests/tests_sysconfig.yml similarity index 100% rename from tests/test_sysconfig.yml rename to tests/tests_sysconfig.yml From 8414fd599468926e071e9845f71048031a5eb6c4 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 21 Oct 2020 18:30:33 +0200 Subject: [PATCH 4/5] tests: Remove trailing newlines to satisfy galaxy linters --- tests/tests_match.yml | 1 - tests/tests_match_iterate.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/tests_match.yml b/tests/tests_match.yml index e409da6..2838fad 100644 --- a/tests/tests_match.yml +++ b/tests/tests_match.yml @@ -68,4 +68,3 @@ - "'Match User sftponly' in config.stdout" - "'Match User root' in config.stdout" tags: tests::verify - diff --git a/tests/tests_match_iterate.yml b/tests/tests_match_iterate.yml index fc3496a..bec4030 100644 --- a/tests/tests_match_iterate.yml +++ b/tests/tests_match_iterate.yml @@ -66,4 +66,3 @@ - "'Match User sftponly' in config.stdout" - "'Match User root' in config.stdout" tags: tests::verify - From a80105069c8866fb8b4cacb01b2da3801dcd4fff Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 21 Oct 2020 18:32:06 +0200 Subject: [PATCH 5/5] Run yamllint with galaxy configuration to avoid quality penalty --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cd47544..258a7dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ os: linux dist: focal language: python +addons: + apt_packages: + - yamllint notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ @@ -14,9 +17,13 @@ install: - "{ echo '[defaults]'; echo 'roles_path = ../'; echo 'deprecation_warnings=False'; } >> ansible.cfg" script: - # Test 0: Check the roles syntax. + # Test 0a: Check the roles syntax. - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --syntax-check" + # Test 0b: Run yamllint with galaxy configuration to avoid quality score penalty + - wget https://raw.githubusercontent.com/ansible/galaxy/devel/galaxy/importer/linters/yamllint.yaml + - "yamllint -c yamllint.yaml **/*.yml" + # Test 1a: Run the role - "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local --become -v"