diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 82ab0c83f4..99767c6d52 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -310,6 +310,8 @@ stages: test: ubuntu1804 - name: Ubuntu 20.04 test: ubuntu2004 + - name: Alpine 3 + test: alpine3 groups: - 1 - 2 @@ -348,6 +350,8 @@ stages: test: fedora33 - name: openSUSE 15 py2 test: opensuse15py2 + - name: Alpine 3 + test: alpine3 groups: - 2 - 3 @@ -382,6 +386,26 @@ stages: - 2 - 3 +### Community Docker + - stage: Docker_community_devel + displayName: Docker (community images) devel + dependsOn: [] + jobs: + - template: templates/matrix.yml + parameters: + testFormat: devel/linux-community/{0} + targets: + - name: Debian Bullseye + test: debian-bullseye/3.9 + - name: ArchLinux + test: archlinux/3.10 + - name: CentOS Stream 8 + test: centos-stream8/3.8 + groups: + - 1 + - 2 + - 3 + ### Cloud - stage: Cloud_devel displayName: Cloud devel @@ -457,6 +481,7 @@ stages: - Docker_2_10 - Docker_2_11 - Docker_2_12 + - Docker_community_devel - Cloud_devel - Cloud_2_9 - Cloud_2_10 diff --git a/tests/integration/targets/alternatives/tasks/main.yml b/tests/integration/targets/alternatives/tasks/main.yml index 3503afe1b3..feb55b9685 100644 --- a/tests/integration/targets/alternatives/tasks/main.yml +++ b/tests/integration/targets/alternatives/tasks/main.yml @@ -68,4 +68,13 @@ # in chkconfig-1.7-2 fails when /etc/alternatives/dummy link is missing, # error is: 'failed to read link /usr/bin/dummy: No such file or directory'. # Moreover Fedora 24 is no longer maintained. - when: ansible_distribution != 'Fedora' or ansible_distribution_major_version|int > 24 + # + # *Disable tests on Arch Linux* + # TODO: figure out whether there is an alternatives tool for Arch Linux + # + # *Disable tests on Alpine* + # TODO: figure out whether there is an alternatives tool for Alpine + when: + - ansible_distribution != 'Fedora' or ansible_distribution_major_version|int > 24 + - ansible_distribution != 'Archlinux' + - ansible_distribution != 'Alpine' diff --git a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml index faa366563a..d466ed0089 100644 --- a/tests/integration/targets/cloud_init_data_facts/tasks/main.yml +++ b/tests/integration/targets/cloud_init_data_facts/tasks/main.yml @@ -15,6 +15,8 @@ when: - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int == 14) - not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3) + - not (ansible_distribution == 'Archlinux') # TODO: package seems to be broken, cannot be downloaded from mirrors? + - not (ansible_distribution == 'Alpine') # TODO: not sure what's wrong here, the module doesn't return what the tests expect block: - name: setup install cloud-init package: diff --git a/tests/integration/targets/consul/tasks/consul_session.yml b/tests/integration/targets/consul/tasks/consul_session.yml index a5490ec6c2..1827c9c381 100644 --- a/tests/integration/targets/consul/tasks/consul_session.yml +++ b/tests/integration/targets/consul/tasks/consul_session.yml @@ -82,50 +82,48 @@ that: - result is failed -- when: pyopenssl_version.stdout is version('0.15', '>=') - block: - - name: ensure SSL certificate is checked - consul_session: - state: info - id: '{{ session_id }}' - port: 8501 - scheme: https - register: result - ignore_errors: True +- name: ensure SSL certificate is checked + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + register: result + ignore_errors: True - - name: previous task should fail since certificate is not known - assert: - that: - - result is failed - - "'certificate verify failed' in result.msg" +- name: previous task should fail since certificate is not known + assert: + that: + - result is failed + - "'certificate verify failed' in result.msg" - - name: ensure SSL certificate isn't checked when validate_certs is disabled - consul_session: - state: info - id: '{{ session_id }}' - port: 8501 - scheme: https - validate_certs: False - register: result +- name: ensure SSL certificate isn't checked when validate_certs is disabled + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + validate_certs: False + register: result - - name: previous task should succeed since certificate isn't checked - assert: - that: - - result is changed +- name: previous task should succeed since certificate isn't checked + assert: + that: + - result is changed - - name: ensure a secure connection is possible - consul_session: - state: info - id: '{{ session_id }}' - port: 8501 - scheme: https - environment: - REQUESTS_CA_BUNDLE: '{{ remote_dir }}/cert.pem' - register: result +- name: ensure a secure connection is possible + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + environment: + REQUESTS_CA_BUNDLE: '{{ remote_dir }}/cert.pem' + register: result - - assert: - that: - - result is changed +- assert: + that: + - result is changed - name: delete a session consul_session: diff --git a/tests/integration/targets/consul/tasks/main.yml b/tests/integration/targets/consul/tasks/main.yml index ae7d1f8542..1f7edce304 100644 --- a/tests/integration/targets/consul/tasks/main.yml +++ b/tests/integration/targets/consul/tasks/main.yml @@ -9,9 +9,6 @@ consul_uri: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/consul/consul_{{ consul_version }}_{{ ansible_system | lower }}_{{ consul_arch }}.zip consul_cmd: '{{ remote_tmp_dir }}/consul' block: - - name: register pyOpenSSL version - command: '{{ ansible_python_interpreter }} -c ''import OpenSSL; print(OpenSSL.__version__)''' - register: pyopenssl_version - name: Install requests<2.20 (CentOS/RHEL 6) pip: name: requests<2.20 @@ -23,25 +20,23 @@ name: python-consul register: result until: result is success - - when: pyopenssl_version.stdout is version('0.15', '>=') - block: - - name: Generate privatekey - community.crypto.openssl_privatekey: - path: '{{ remote_tmp_dir }}/privatekey.pem' - - name: Generate CSR - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/csr.csr' - privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' - subject: - commonName: localhost - - name: Generate selfsigned certificate - register: selfsigned_certificate - community.crypto.x509_certificate: - path: '{{ remote_tmp_dir }}/cert.pem' - csr_path: '{{ remote_tmp_dir }}/csr.csr' - privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' - provider: selfsigned - selfsigned_digest: sha256 + - name: Generate privatekey + community.crypto.openssl_privatekey: + path: '{{ remote_tmp_dir }}/privatekey.pem' + - name: Generate CSR + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/csr.csr' + privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' + subject: + commonName: localhost + - name: Generate selfsigned certificate + register: selfsigned_certificate + community.crypto.x509_certificate: + path: '{{ remote_tmp_dir }}/cert.pem' + csr_path: '{{ remote_tmp_dir }}/csr.csr' + privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' + provider: selfsigned + selfsigned_digest: sha256 - name: Install unzip package: name: unzip diff --git a/tests/integration/targets/consul/templates/consul_config.hcl.j2 b/tests/integration/targets/consul/templates/consul_config.hcl.j2 index 9af06f02e9..811c124bb7 100644 --- a/tests/integration/targets/consul/templates/consul_config.hcl.j2 +++ b/tests/integration/targets/consul/templates/consul_config.hcl.j2 @@ -3,11 +3,7 @@ server = true pid_file = "{{ remote_dir }}/consul.pid" ports { http = 8500 - {% if pyopenssl_version.stdout is version('0.15', '>=') %} https = 8501 - {% endif %} } -{% if pyopenssl_version.stdout is version('0.15', '>=') %} key_file = "{{ remote_dir }}/privatekey.pem" cert_file = "{{ remote_dir }}/cert.pem" -{% endif %} diff --git a/tests/integration/targets/cronvar/tasks/main.yml b/tests/integration/targets/cronvar/tasks/main.yml index 4e95258e6b..8d47eb19cf 100644 --- a/tests/integration/targets/cronvar/tasks/main.yml +++ b/tests/integration/targets/cronvar/tasks/main.yml @@ -3,112 +3,115 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### -- name: Create EMAIL cron var - cronvar: - name: EMAIL - value: doug@ansibmod.con.com - register: create_cronvar1 +- when: + - not (ansible_os_family == 'Alpine' and ansible_distribution_version is version('3.15', '<')) # TODO + block: + - name: Create EMAIL cron var + cronvar: + name: EMAIL + value: doug@ansibmod.con.com + register: create_cronvar1 -- name: Create EMAIL cron var again - cronvar: - name: EMAIL - value: doug@ansibmod.con.com - register: create_cronvar2 + - name: Create EMAIL cron var again + cronvar: + name: EMAIL + value: doug@ansibmod.con.com + register: create_cronvar2 -- name: Check cron var value - shell: crontab -l -u root | grep -c EMAIL=doug@ansibmod.con.com - register: varcheck1 + - name: Check cron var value + shell: crontab -l -u root | grep -c EMAIL=doug@ansibmod.con.com + register: varcheck1 -- name: Modify EMAIL cron var - cronvar: - name: EMAIL - value: jane@ansibmod.con.com - register: create_cronvar3 + - name: Modify EMAIL cron var + cronvar: + name: EMAIL + value: jane@ansibmod.con.com + register: create_cronvar3 -- name: Check cron var value again - shell: crontab -l -u root | grep -c EMAIL=jane@ansibmod.con.com - register: varcheck2 + - name: Check cron var value again + shell: crontab -l -u root | grep -c EMAIL=jane@ansibmod.con.com + register: varcheck2 -- name: Remove EMAIL cron var - cronvar: - name: EMAIL - state: absent - register: remove_cronvar1 + - name: Remove EMAIL cron var + cronvar: + name: EMAIL + state: absent + register: remove_cronvar1 -- name: Remove EMAIL cron var again - cronvar: - name: EMAIL - state: absent - register: remove_cronvar2 + - name: Remove EMAIL cron var again + cronvar: + name: EMAIL + state: absent + register: remove_cronvar2 -- name: Check cron var value again - shell: crontab -l -u root | grep -c EMAIL - register: varcheck3 - failed_when: varcheck3.rc == 0 + - name: Check cron var value again + shell: crontab -l -u root | grep -c EMAIL + register: varcheck3 + failed_when: varcheck3.rc == 0 -- name: Add cron var to custom file - cronvar: - name: TESTVAR - value: somevalue - cron_file: cronvar_test - register: custom_cronfile1 + - name: Add cron var to custom file + cronvar: + name: TESTVAR + value: somevalue + cron_file: cronvar_test + register: custom_cronfile1 -- name: Add cron var to custom file again - cronvar: - name: TESTVAR - value: somevalue - cron_file: cronvar_test - register: custom_cronfile2 + - name: Add cron var to custom file again + cronvar: + name: TESTVAR + value: somevalue + cron_file: cronvar_test + register: custom_cronfile2 -- name: Check cron var value in custom file - command: grep -c TESTVAR=somevalue {{ cron_config_path }}/cronvar_test - register: custom_varcheck1 + - name: Check cron var value in custom file + command: grep -c TESTVAR=somevalue {{ cron_config_path }}/cronvar_test + register: custom_varcheck1 -- name: Change cron var in custom file - cronvar: - name: TESTVAR - value: newvalue - cron_file: cronvar_test - register: custom_cronfile3 + - name: Change cron var in custom file + cronvar: + name: TESTVAR + value: newvalue + cron_file: cronvar_test + register: custom_cronfile3 -- name: Check cron var value in custom file - command: grep -c TESTVAR=newvalue {{ cron_config_path }}/cronvar_test - register: custom_varcheck2 + - name: Check cron var value in custom file + command: grep -c TESTVAR=newvalue {{ cron_config_path }}/cronvar_test + register: custom_varcheck2 -- name: Remove cron var from custom file - cronvar: - name: TESTVAR - value: newvalue - cron_file: cronvar_test - state: absent - register: custom_remove_cronvar1 + - name: Remove cron var from custom file + cronvar: + name: TESTVAR + value: newvalue + cron_file: cronvar_test + state: absent + register: custom_remove_cronvar1 -- name: Remove cron var from custom file again - cronvar: - name: TESTVAR - value: newvalue - cron_file: cronvar_test - state: absent - register: custom_remove_cronvar2 + - name: Remove cron var from custom file again + cronvar: + name: TESTVAR + value: newvalue + cron_file: cronvar_test + state: absent + register: custom_remove_cronvar2 -- name: Check cron var value - command: grep -c TESTVAR=newvalue {{ cron_config_path }}/cronvar_test - register: custom_varcheck3 - failed_when: custom_varcheck3.rc == 0 + - name: Check cron var value + command: grep -c TESTVAR=newvalue {{ cron_config_path }}/cronvar_test + register: custom_varcheck3 + failed_when: custom_varcheck3.rc == 0 -- name: Esure cronvar tasks did the right thing - assert: - that: - - create_cronvar1 is changed - - create_cronvar2 is not changed - - create_cronvar3 is changed - - remove_cronvar1 is changed - - remove_cronvar2 is not changed - - varcheck1.stdout == '1' - - varcheck2.stdout == '1' - - varcheck3.stdout == '0' - - custom_remove_cronvar1 is changed - - custom_remove_cronvar2 is not changed - - custom_varcheck1.stdout == '1' - - custom_varcheck2.stdout == '1' - - custom_varcheck3.stdout == '0' + - name: Esure cronvar tasks did the right thing + assert: + that: + - create_cronvar1 is changed + - create_cronvar2 is not changed + - create_cronvar3 is changed + - remove_cronvar1 is changed + - remove_cronvar2 is not changed + - varcheck1.stdout == '1' + - varcheck2.stdout == '1' + - varcheck3.stdout == '0' + - custom_remove_cronvar1 is changed + - custom_remove_cronvar2 is not changed + - custom_varcheck1.stdout == '1' + - custom_varcheck2.stdout == '1' + - custom_varcheck3.stdout == '0' diff --git a/tests/integration/targets/django_manage/tasks/main.yaml b/tests/integration/targets/django_manage/tasks/main.yaml index 0421739acc..59104d788a 100644 --- a/tests/integration/targets/django_manage/tasks/main.yaml +++ b/tests/integration/targets/django_manage/tasks/main.yaml @@ -8,6 +8,18 @@ suffix: .django_manage register: tmp_django_root +- name: Install virtualenv + package: + name: virtualenv + state: present + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' + +- name: Install virtualenv + package: + name: python-virtualenv + state: present + when: ansible_os_family == 'Archlinux' + - name: Install required library pip: name: django diff --git a/tests/integration/targets/filesize/tasks/main.yml b/tests/integration/targets/filesize/tasks/main.yml index 14415dac9a..d156e6c56f 100644 --- a/tests/integration/targets/filesize/tasks/main.yml +++ b/tests/integration/targets/filesize/tasks/main.yml @@ -29,6 +29,7 @@ include_tasks: sparse.yml when: - not (ansible_os_family == 'Darwin' and ansible_distribution_version is version('11', '<')) + - not (ansible_os_family == 'Alpine') # TODO figure out why it fails - name: Include tasks to test playing with symlinks include_tasks: symlinks.yml diff --git a/tests/integration/targets/filesystem/tasks/create_fs.yml b/tests/integration/targets/filesystem/tasks/create_fs.yml index 3c92197c0a..23f6e526c2 100644 --- a/tests/integration/targets/filesystem/tasks/create_fs.yml +++ b/tests/integration/targets/filesystem/tasks/create_fs.yml @@ -1,5 +1,5 @@ --- -- name: "Create filesystem" +- name: "Create filesystem ({{ fstype }})" community.general.filesystem: dev: '{{ dev }}' fstype: '{{ fstype }}' diff --git a/tests/integration/targets/filesystem/tasks/main.yml b/tests/integration/targets/filesystem/tasks/main.yml index 864c9f7b5d..7de9df8e97 100644 --- a/tests/integration/targets/filesystem/tasks/main.yml +++ b/tests/integration/targets/filesystem/tasks/main.yml @@ -48,10 +48,18 @@ # reiserfs-utils package not available with Fedora 35 on CI - 'not (ansible_distribution == "Fedora" and (ansible_facts.distribution_major_version | int >= 35) and item.0.key == "reiserfs")' + # reiserfs packages apparently not available with Alpine + - 'not (ansible_distribution == "Alpine" and item.0.key == "reiserfs")' # ocfs2 only available on Debian based distributions - 'not (item.0.key == "ocfs2" and ansible_os_family != "Debian")' # Tests use losetup which can not be used inside unprivileged container - 'not (item.0.key == "lvm" and ansible_virtualization_type in ["docker", "container", "containerd"])' + # vfat resizing fails on Debian (but not Ubuntu) + - 'not (item.0.key == "vfat" and ansible_distribution == "Debian")' # TODO: figure out why it fails, fix it! + # vfat resizing fails on ArchLinux + - 'not (item.0.key == "vfat" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it! + # btrfs-progs cannot be installed on ArchLinux + - 'not (item.0.key == "btrfs" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it! # On CentOS 6 shippable containers, wipefs seems unable to remove vfat signatures - 'not (ansible_distribution == "CentOS" and ansible_distribution_version is version("7.0", "<") and @@ -65,6 +73,9 @@ - 'not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and item.0.key == "xfs" and ansible_python.version.major == 2)' + # TODO: something seems to be broken on Alpine + - 'not (ansible_distribution == "Alpine")' + loop: "{{ query('dict', tested_filesystems)|product(['create_fs', 'overwrite_another_fs', 'remove_fs'])|list }}" diff --git a/tests/integration/targets/filesystem/tasks/setup.yml b/tests/integration/targets/filesystem/tasks/setup.yml index c7b27b715b..b39b5418b6 100644 --- a/tests/integration/targets/filesystem/tasks/setup.yml +++ b/tests/integration/targets/filesystem/tasks/setup.yml @@ -21,6 +21,7 @@ - not (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('16.04', '<=')) - ansible_system != "FreeBSD" - not (ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('8', '>=')) + - ansible_os_family != 'Archlinux' # TODO - name: "Install btrfs tools (Ubuntu <= 16.04)" ansible.builtin.package: @@ -60,7 +61,7 @@ state: present when: - ansible_system == 'Linux' - - ansible_os_family not in ['Suse', 'RedHat'] + - ansible_os_family not in ['Suse', 'RedHat', 'Alpine'] - name: "Install reiserfs progs (FreeBSD)" ansible.builtin.package: @@ -111,6 +112,7 @@ - ansible_system == 'Linux' - ansible_os_family != 'Suse' - ansible_os_family != 'RedHat' or (ansible_distribution == 'CentOS' and ansible_distribution_version is version('7.0', '==')) + - ansible_os_family != 'Alpine' block: - name: "Install fatresize" ansible.builtin.package: diff --git a/tests/integration/targets/gem/tasks/main.yml b/tests/integration/targets/gem/tasks/main.yml index 4674fb1075..1e6cd25ff7 100644 --- a/tests/integration/targets/gem/tasks/main.yml +++ b/tests/integration/targets/gem/tasks/main.yml @@ -21,201 +21,205 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -- include_vars: '{{ item }}' - with_first_found: - - files: - - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' - - '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml' - - '{{ ansible_os_family }}.yml' - - 'default.yml' - paths: '../vars' +- when: + - not (ansible_os_family == 'Alpine') # TODO + block: -- name: Install dependencies for test - package: - name: "{{ item }}" - state: present - loop: "{{ test_packages }}" - when: ansible_distribution != "MacOSX" + - include_vars: '{{ item }}' + with_first_found: + - files: + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' + - '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml' + - '{{ ansible_os_family }}.yml' + - 'default.yml' + paths: '../vars' -- name: Install a gem - gem: - name: gist - state: present - register: install_gem_result - ignore_errors: yes + - name: Install dependencies for test + package: + name: "{{ item }}" + state: present + loop: "{{ test_packages }}" + when: ansible_distribution != "MacOSX" -# when running as root on Fedora, '--install-dir' is set in the os defaults which is -# incompatible with '--user-install', we ignore this error for this case only -- name: fail if failed to install gem - fail: - msg: "failed to install gem: {{ install_gem_result.msg }}" - when: - - install_gem_result is failed - - not (ansible_user_uid == 0 and "User --install-dir or --user-install but not both" not in install_gem_result.msg) - -- block: - - name: List gems - command: gem list - register: current_gems - - - name: Ensure gem was installed - assert: - that: - - install_gem_result is changed - - current_gems.stdout is search('gist\s+\([0-9.]+\)') - - - name: Remove a gem + - name: Install a gem gem: name: gist - state: absent - register: remove_gem_results + state: present + register: install_gem_result + ignore_errors: yes - - name: List gems - command: gem list - register: current_gems + # when running as root on Fedora, '--install-dir' is set in the os defaults which is + # incompatible with '--user-install', we ignore this error for this case only + - name: fail if failed to install gem + fail: + msg: "failed to install gem: {{ install_gem_result.msg }}" + when: + - install_gem_result is failed + - not (ansible_user_uid == 0 and "User --install-dir or --user-install but not both" not in install_gem_result.msg) - - name: Verify gem is not installed + - block: + - name: List gems + command: gem list + register: current_gems + + - name: Ensure gem was installed + assert: + that: + - install_gem_result is changed + - current_gems.stdout is search('gist\s+\([0-9.]+\)') + + - name: Remove a gem + gem: + name: gist + state: absent + register: remove_gem_results + + - name: List gems + command: gem list + register: current_gems + + - name: Verify gem is not installed + assert: + that: + - remove_gem_results is changed + - current_gems.stdout is not search('gist\s+\([0-9.]+\)') + when: not install_gem_result is failed + + # install gem in --no-user-install + - block: + - name: Install a gem with --no-user-install + gem: + name: gist + state: present + user_install: no + register: install_gem_result + + - name: List gems + command: gem list + register: current_gems + + - name: Ensure gem was installed + assert: + that: + - install_gem_result is changed + - current_gems.stdout is search('gist\s+\([0-9.]+\)') + + - name: Remove a gem + gem: + name: gist + state: absent + register: remove_gem_results + + - name: List gems + command: gem list + register: current_gems + + - name: Verify gem is not installed + assert: + that: + - remove_gem_results is changed + - current_gems.stdout is not search('gist\s+\([0-9.]+\)') + when: ansible_user_uid == 0 + + # Check cutom gem directory + - name: Install gem in a custom directory with incorrect options + gem: + name: gist + state: present + install_dir: "{{ remote_tmp_dir }}/gems" + ignore_errors: yes + register: install_gem_fail_result + + - debug: + var: install_gem_fail_result + tags: debug + + - name: Ensure previous task failed assert: that: - - remove_gem_results is changed - - current_gems.stdout is not search('gist\s+\([0-9.]+\)') - when: not install_gem_result is failed + - install_gem_fail_result is failed + - install_gem_fail_result.msg == 'install_dir requires user_install=false' -# install gem in --no-user-install -- block: - - name: Install a gem with --no-user-install + - name: Install a gem in a custom directory gem: name: gist state: present user_install: no + install_dir: "{{ remote_tmp_dir }}/gems" register: install_gem_result - - name: List gems - command: gem list - register: current_gems + - name: Find gems in custom directory + find: + paths: "{{ remote_tmp_dir }}/gems/gems" + file_type: directory + contains: gist + register: gem_search - - name: Ensure gem was installed + - name: Ensure gem was installed in custom directory assert: that: - install_gem_result is changed - - current_gems.stdout is search('gist\s+\([0-9.]+\)') + - gem_search.files[0].path is search('gist-[0-9.]+') + ignore_errors: yes - - name: Remove a gem + - name: Remove a gem in a custom directory gem: name: gist state: absent - register: remove_gem_results + user_install: no + install_dir: "{{ remote_tmp_dir }}/gems" + register: install_gem_result - - name: List gems - command: gem list - register: current_gems + - name: Find gems in custom directory + find: + paths: "{{ remote_tmp_dir }}/gems/gems" + file_type: directory + contains: gist + register: gem_search - - name: Verify gem is not installed + - name: Ensure gem was removed in custom directory assert: that: - - remove_gem_results is changed - - current_gems.stdout is not search('gist\s+\([0-9.]+\)') - when: ansible_user_uid == 0 + - install_gem_result is changed + - gem_search.files | length == 0 -# Check cutom gem directory -- name: Install gem in a custom directory with incorrect options - gem: - name: gist - state: present - install_dir: "{{ remote_tmp_dir }}/gems" - ignore_errors: yes - register: install_gem_fail_result + # Custom directory for executables (--bindir) + - name: Install gem with custom bindir + gem: + name: gist + state: present + bindir: "{{ remote_tmp_dir }}/custom_bindir" + norc: yes + user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL + register: install_gem_result -- debug: - var: install_gem_fail_result - tags: debug + - name: Get stats of gem executable + stat: + path: "{{ remote_tmp_dir }}/custom_bindir/gist" + register: gem_bindir_stat -- name: Ensure previous task failed - assert: - that: - - install_gem_fail_result is failed - - install_gem_fail_result.msg == 'install_dir requires user_install=false' + - name: Ensure gem executable was installed in custom directory + assert: + that: + - install_gem_result is changed + - gem_bindir_stat.stat.exists and gem_bindir_stat.stat.isreg -- name: Install a gem in a custom directory - gem: - name: gist - state: present - user_install: no - install_dir: "{{ remote_tmp_dir }}/gems" - register: install_gem_result + - name: Remove gem with custom bindir + gem: + name: gist + state: absent + bindir: "{{ remote_tmp_dir }}/custom_bindir" + norc: yes + user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL + register: install_gem_result -- name: Find gems in custom directory - find: - paths: "{{ remote_tmp_dir }}/gems/gems" - file_type: directory - contains: gist - register: gem_search + - name: Get stats of gem executable + stat: + path: "{{ remote_tmp_dir }}/custom_bindir/gist" + register: gem_bindir_stat -- name: Ensure gem was installed in custom directory - assert: - that: - - install_gem_result is changed - - gem_search.files[0].path is search('gist-[0-9.]+') - ignore_errors: yes - -- name: Remove a gem in a custom directory - gem: - name: gist - state: absent - user_install: no - install_dir: "{{ remote_tmp_dir }}/gems" - register: install_gem_result - -- name: Find gems in custom directory - find: - paths: "{{ remote_tmp_dir }}/gems/gems" - file_type: directory - contains: gist - register: gem_search - -- name: Ensure gem was removed in custom directory - assert: - that: - - install_gem_result is changed - - gem_search.files | length == 0 - -# Custom directory for executables (--bindir) -- name: Install gem with custom bindir - gem: - name: gist - state: present - bindir: "{{ remote_tmp_dir }}/custom_bindir" - norc: yes - user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL - register: install_gem_result - -- name: Get stats of gem executable - stat: - path: "{{ remote_tmp_dir }}/custom_bindir/gist" - register: gem_bindir_stat - -- name: Ensure gem executable was installed in custom directory - assert: - that: - - install_gem_result is changed - - gem_bindir_stat.stat.exists and gem_bindir_stat.stat.isreg - -- name: Remove gem with custom bindir - gem: - name: gist - state: absent - bindir: "{{ remote_tmp_dir }}/custom_bindir" - norc: yes - user_install: no # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL - register: install_gem_result - -- name: Get stats of gem executable - stat: - path: "{{ remote_tmp_dir }}/custom_bindir/gist" - register: gem_bindir_stat - -- name: Ensure gem executable was removed from custom directory - assert: - that: - - install_gem_result is changed - - not gem_bindir_stat.stat.exists + - name: Ensure gem executable was removed from custom directory + assert: + that: + - install_gem_result is changed + - not gem_bindir_stat.stat.exists diff --git a/tests/integration/targets/homectl/tasks/main.yml b/tests/integration/targets/homectl/tasks/main.yml index a69d0f40e5..ded6173759 100644 --- a/tests/integration/targets/homectl/tasks/main.yml +++ b/tests/integration/targets/homectl/tasks/main.yml @@ -171,4 +171,6 @@ - jake_incorrect_pass_out is not changed and jake_incorrect_pass_out is failed and jake_incorrect_pass_out.msg == 'User exists but password is incorrect!' # homectl was first introduced in systemd 245 so check version >= 245 and make sure system has systemd and homectl command - when: systemd_version.rc == 0 and (systemd_version.stdout | regex_search('[0-9][0-9][0-9]') | int >= 245) and homectl_version.rc == 0 \ No newline at end of file + when: + - systemd_version.rc == 0 and (systemd_version.stdout | regex_search('[0-9][0-9][0-9]') | int >= 245) and homectl_version.rc == 0 + - ansible_distribution != 'Archlinux' # TODO! diff --git a/tests/integration/targets/iso_extract/vars/Alpine.yml b/tests/integration/targets/iso_extract/vars/Alpine.yml new file mode 100644 index 0000000000..f9e7ca1a9a --- /dev/null +++ b/tests/integration/targets/iso_extract/vars/Alpine.yml @@ -0,0 +1 @@ +iso_extract_7zip_package: p7zip diff --git a/tests/integration/targets/iso_extract/vars/Archlinux.yml b/tests/integration/targets/iso_extract/vars/Archlinux.yml new file mode 100644 index 0000000000..f9e7ca1a9a --- /dev/null +++ b/tests/integration/targets/iso_extract/vars/Archlinux.yml @@ -0,0 +1 @@ +iso_extract_7zip_package: p7zip diff --git a/tests/integration/targets/iso_extract/vars/Debian.yml b/tests/integration/targets/iso_extract/vars/Debian.yml new file mode 100644 index 0000000000..219c495764 --- /dev/null +++ b/tests/integration/targets/iso_extract/vars/Debian.yml @@ -0,0 +1 @@ +iso_extract_7zip_package: p7zip-full diff --git a/tests/integration/targets/lookup_passwordstore/vars/Alpine.yml b/tests/integration/targets/lookup_passwordstore/vars/Alpine.yml new file mode 100644 index 0000000000..3d1c4d45d5 --- /dev/null +++ b/tests/integration/targets/lookup_passwordstore/vars/Alpine.yml @@ -0,0 +1,2 @@ +passwordstore_packages: + - pass diff --git a/tests/integration/targets/lookup_passwordstore/vars/Archlinux.yml b/tests/integration/targets/lookup_passwordstore/vars/Archlinux.yml new file mode 100644 index 0000000000..3d1c4d45d5 --- /dev/null +++ b/tests/integration/targets/lookup_passwordstore/vars/Archlinux.yml @@ -0,0 +1,2 @@ +passwordstore_packages: + - pass diff --git a/tests/integration/targets/monit/vars/Alpine.yml b/tests/integration/targets/monit/vars/Alpine.yml new file mode 100644 index 0000000000..cb76bac9e4 --- /dev/null +++ b/tests/integration/targets/monit/vars/Alpine.yml @@ -0,0 +1 @@ +monitrc: "/etc/monitrc" diff --git a/tests/integration/targets/monit/vars/Archlinux.yml b/tests/integration/targets/monit/vars/Archlinux.yml new file mode 100644 index 0000000000..cb76bac9e4 --- /dev/null +++ b/tests/integration/targets/monit/vars/Archlinux.yml @@ -0,0 +1 @@ +monitrc: "/etc/monitrc" diff --git a/tests/integration/targets/nomad/tasks/main.yml b/tests/integration/targets/nomad/tasks/main.yml index 6e1c4a254e..abf78aad98 100644 --- a/tests/integration/targets/nomad/tasks/main.yml +++ b/tests/integration/targets/nomad/tasks/main.yml @@ -1,6 +1,9 @@ - name: Skip unsupported platforms meta: end_play - when: ansible_distribution == 'CentOS' and ansible_distribution_major_version is not version('7', '>=') + # TODO: figure out why Alpine does not work! + when: | + ansible_distribution == 'CentOS' and ansible_distribution_major_version is not version('7', '>=') + or ansible_distribution == 'Alpine' - name: Install Nomad and test vars: @@ -9,10 +12,6 @@ nomad_cmd: '{{ remote_tmp_dir }}/nomad' block: - - name: register pyOpenSSL version - command: '{{ ansible_python_interpreter }} -c ''import OpenSSL; print(OpenSSL.__version__)''' - register: pyopenssl_version - - name: Install requests<2.20 (CentOS/RHEL 6) pip: name: requests<2.20 @@ -32,27 +31,25 @@ register: result until: result is success - - when: pyopenssl_version.stdout is version('0.15', '>=') - block: - - name: Generate privatekey - community.crypto.openssl_privatekey: - path: '{{ remote_tmp_dir }}/privatekey.pem' + - name: Generate privatekey + community.crypto.openssl_privatekey: + path: '{{ remote_tmp_dir }}/privatekey.pem' - - name: Generate CSR - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/csr.csr' - privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' - subject: - commonName: localhost + - name: Generate CSR + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/csr.csr' + privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' + subject: + commonName: localhost - - name: Generate selfsigned certificate - register: selfsigned_certificate - community.crypto.x509_certificate: - path: '{{ remote_tmp_dir }}/cert.pem' - csr_path: '{{ remote_tmp_dir }}/csr.csr' - privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' - provider: selfsigned - selfsigned_digest: sha256 + - name: Generate selfsigned certificate + register: selfsigned_certificate + community.crypto.x509_certificate: + path: '{{ remote_tmp_dir }}/cert.pem' + csr_path: '{{ remote_tmp_dir }}/csr.csr' + privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' + provider: selfsigned + selfsigned_digest: sha256 - name: Install unzip package: diff --git a/tests/integration/targets/npm/tasks/main.yml b/tests/integration/targets/npm/tasks/main.yml index c3971fd91d..8e1d388e2c 100644 --- a/tests/integration/targets/npm/tasks/main.yml +++ b/tests/integration/targets/npm/tasks/main.yml @@ -20,21 +20,24 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . - # ------------------------------------------------------------- # Setup steps -# expand remote path -- command: 'echo {{ remote_tmp_dir }}' - register: echo -- set_fact: - remote_dir: '{{ echo.stdout }}' +- when: + - not (ansible_os_family == 'Alpine') # TODO + block: -- include_tasks: run.yml - vars: - nodejs_version: '{{ item }}' - nodejs_path: 'node-v{{ nodejs_version }}-{{ ansible_system|lower }}-x{{ ansible_userspace_bits }}' - with_items: - - 7.10.1 # provides npm 4.2.0 (last npm < 5 released) - - 8.0.0 # provides npm 5.0.0 - - 8.2.0 # provides npm 5.3.0 (output change with this version) + # expand remote path + - command: 'echo {{ remote_tmp_dir }}' + register: echo + - set_fact: + remote_dir: '{{ echo.stdout }}' + + - include_tasks: run.yml + vars: + nodejs_version: '{{ item }}' + nodejs_path: 'node-v{{ nodejs_version }}-{{ ansible_system|lower }}-x{{ ansible_userspace_bits }}' + with_items: + - 7.10.1 # provides npm 4.2.0 (last npm < 5 released) + - 8.0.0 # provides npm 5.0.0 + - 8.2.0 # provides npm 5.3.0 (output change with this version) diff --git a/tests/integration/targets/odbc/defaults/main.yml b/tests/integration/targets/odbc/defaults/main.yml index f6efa75078..aa8eeb74a5 100644 --- a/tests/integration/targets/odbc/defaults/main.yml +++ b/tests/integration/targets/odbc/defaults/main.yml @@ -5,6 +5,13 @@ my_pass: 'md5d5e044ccd9b4b8adc89e8fed2eb0db8a' my_pass_decrypted: '6EjMk 0" - - "exactpidmatch.pids == []" - - "pattern_pid_match.pids | join(' ') == newpid.content | b64decode | trim" - - "caseinsensitive_pattern_pid_match.pids | join(' ') == newpid.content | b64decode | trim" - - newpid.content | b64decode | trim | int in match_all.pids + - name: "Checking that .* includes test pid" + pids: + pattern: .* + register: match_all -- name: "Register output of bad input pattern" - pids: - pattern: (unterminated - register: bad_pattern_result - ignore_errors: true + - name: "Reading pid from the file" + slurp: + src: "{{ remote_tmp_dir }}/obtainpid.txt" + register: newpid -- name: "Verify that bad input pattern result is failed" - assert: - that: - - bad_pattern_result is failed \ No newline at end of file + - name: "Verify that the Process IDs (PIDs) returned is not empty and also equal to the PIDs obtained in console" + assert: + that: + - "pids.pids | join(' ') == newpid.content | b64decode | trim" + - "pids.pids | length > 0" + - "exactpidmatch.pids == []" + - "pattern_pid_match.pids | join(' ') == newpid.content | b64decode | trim" + - "caseinsensitive_pattern_pid_match.pids | join(' ') == newpid.content | b64decode | trim" + - newpid.content | b64decode | trim | int in match_all.pids + + - name: "Register output of bad input pattern" + pids: + pattern: (unterminated + register: bad_pattern_result + ignore_errors: true + + - name: "Verify that bad input pattern result is failed" + assert: + that: + - bad_pattern_result is failed \ No newline at end of file diff --git a/tests/integration/targets/setup_cron/tasks/main.yml b/tests/integration/targets/setup_cron/tasks/main.yml index bacdfaf382..a53f0ecd61 100644 --- a/tests/integration/targets/setup_cron/tasks/main.yml +++ b/tests/integration/targets/setup_cron/tasks/main.yml @@ -3,67 +3,70 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### -- name: Include distribution specific variables - include_vars: '{{ lookup(''first_found'', search) }}' - vars: - search: - files: - - '{{ ansible_distribution | lower }}.yml' - - '{{ ansible_os_family | lower }}.yml' - - '{{ ansible_system | lower }}.yml' - - default.yml - paths: - - vars -- name: install cron package - package: - name: '{{ cron_pkg }}' - when: cron_pkg | default(false, true) - register: cron_package_installed - until: cron_package_installed is success -- when: faketime_pkg | default(false, true) +- when: + - not (ansible_os_family == 'Alpine' and ansible_distribution_version is version('3.15', '<')) # TODO block: - - name: install cron and faketime packages + - name: Include distribution specific variables + include_vars: '{{ lookup(''first_found'', search) }}' + vars: + search: + files: + - '{{ ansible_distribution | lower }}.yml' + - '{{ ansible_os_family | lower }}.yml' + - '{{ ansible_system | lower }}.yml' + - default.yml + paths: + - vars + - name: install cron package package: - name: '{{ faketime_pkg }}' - register: faketime_package_installed - until: faketime_package_installed is success - - name: Find libfaketime path - shell: '{{ list_pkg_files }} {{ faketime_pkg }} | grep -F libfaketime.so.1' - args: - warn: false - register: libfaketime_path - - when: ansible_service_mgr == 'systemd' + name: '{{ cron_pkg }}' + when: cron_pkg | default(false, true) + register: cron_package_installed + until: cron_package_installed is success + - when: faketime_pkg | default(false, true) block: - - name: create directory for cron drop-in file - file: - path: /etc/systemd/system/{{ cron_service }}.service.d - state: directory - owner: root - group: root - mode: '0755' - - name: Use faketime with cron service + - name: install cron and faketime packages + package: + name: '{{ faketime_pkg }}' + register: faketime_package_installed + until: faketime_package_installed is success + - name: Find libfaketime path + shell: '{{ list_pkg_files }} {{ faketime_pkg }} | grep -F libfaketime.so.1' + args: + warn: false + register: libfaketime_path + - when: ansible_service_mgr == 'systemd' + block: + - name: create directory for cron drop-in file + file: + path: /etc/systemd/system/{{ cron_service }}.service.d + state: directory + owner: root + group: root + mode: '0755' + - name: Use faketime with cron service + copy: + content: '[Service] + + Environment=LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }} + + Environment="FAKETIME=+0y x10" + + Environment=RANDOM_DELAY=0' + dest: /etc/systemd/system/{{ cron_service }}.service.d/faketime.conf + owner: root + group: root + mode: '0644' + - when: ansible_system == 'FreeBSD' + name: Use faketime with cron service copy: - content: '[Service] - - Environment=LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }} - - Environment="FAKETIME=+0y x10" - - Environment=RANDOM_DELAY=0' - dest: /etc/systemd/system/{{ cron_service }}.service.d/faketime.conf + content: cron_env='LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }} FAKETIME="+0y x10"' + dest: /etc/rc.conf.d/cron owner: root - group: root + group: wheel mode: '0644' - - when: ansible_system == 'FreeBSD' - name: Use faketime with cron service - copy: - content: cron_env='LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }} FAKETIME="+0y x10"' - dest: /etc/rc.conf.d/cron - owner: root - group: wheel - mode: '0644' -- name: enable cron service - service: - daemon-reload: '{{ (ansible_service_mgr == ''systemd'') | ternary(true, omit) }}' - name: '{{ cron_service }}' - state: restarted + - name: enable cron service + service: + daemon-reload: '{{ (ansible_service_mgr == ''systemd'') | ternary(true, omit) }}' + name: '{{ cron_service }}' + state: restarted diff --git a/tests/integration/targets/setup_cron/vars/alpine.yml b/tests/integration/targets/setup_cron/vars/alpine.yml new file mode 100644 index 0000000000..ae713e3a8d --- /dev/null +++ b/tests/integration/targets/setup_cron/vars/alpine.yml @@ -0,0 +1,3 @@ +cron_pkg: cronie +cron_service: cronie +list_pkg_files: apk info -L diff --git a/tests/integration/targets/setup_cron/vars/archlinux.yml b/tests/integration/targets/setup_cron/vars/archlinux.yml new file mode 100644 index 0000000000..2ebe8d11ca --- /dev/null +++ b/tests/integration/targets/setup_cron/vars/archlinux.yml @@ -0,0 +1,3 @@ +cron_pkg: cronie +cron_service: cronie +list_pkg_files: pacman -Ql diff --git a/tests/integration/targets/setup_flatpak_remote/tasks/main.yaml b/tests/integration/targets/setup_flatpak_remote/tasks/main.yaml index d80d364634..65581abed7 100644 --- a/tests/integration/targets/setup_flatpak_remote/tasks/main.yaml +++ b/tests/integration/targets/setup_flatpak_remote/tasks/main.yaml @@ -4,6 +4,9 @@ #################################################################### - name: Set up dummy flatpak repository remote + when: | + ansible_distribution == 'Fedora' or + ansible_distribution == 'Ubuntu' and not ansible_distribution_major_version | int < 16 block: - name: Copy repo into place unarchive: diff --git a/tests/integration/targets/setup_java_keytool/vars/Alpine.yml b/tests/integration/targets/setup_java_keytool/vars/Alpine.yml new file mode 100644 index 0000000000..471da74d6b --- /dev/null +++ b/tests/integration/targets/setup_java_keytool/vars/Alpine.yml @@ -0,0 +1,2 @@ +--- +keytool_package_name: openjdk11-jre-headless diff --git a/tests/integration/targets/setup_java_keytool/vars/Archlinux.yml b/tests/integration/targets/setup_java_keytool/vars/Archlinux.yml new file mode 100644 index 0000000000..15acabe1e5 --- /dev/null +++ b/tests/integration/targets/setup_java_keytool/vars/Archlinux.yml @@ -0,0 +1,2 @@ +--- +keytool_package_name: jre11-openjdk-headless diff --git a/tests/integration/targets/setup_openssl/tasks/main.yml b/tests/integration/targets/setup_openssl/tasks/main.yml index 27d485a83f..a449926eaf 100644 --- a/tests/integration/targets/setup_openssl/tasks/main.yml +++ b/tests/integration/targets/setup_openssl/tasks/main.yml @@ -5,8 +5,17 @@ #################################################################### - name: Include OS-specific variables - include_vars: '{{ ansible_os_family }}.yml' - when: not ansible_os_family == "Darwin" + include_vars: '{{ lookup("first_found", search) }}' + vars: + search: + files: + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' + - '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml' + - '{{ ansible_distribution }}.yml' + - '{{ ansible_os_family }}.yml' + - default.yml + paths: + - vars - name: Install OpenSSL become: True @@ -14,49 +23,38 @@ name: '{{ openssl_package_name }}' when: not ansible_os_family == 'Darwin' -- name: Install pyOpenSSL (Python 3) - become: True - package: - name: '{{ pyopenssl_package_name_python3 }}' - when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '>=') - -- name: Install pyOpenSSL (Python 2) - become: True - package: - name: '{{ pyopenssl_package_name }}' - when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '<') - -- name: Install pyOpenSSL (Darwin) - become: True - pip: - name: pyOpenSSL - extra_args: "-c {{ remote_constraints }}" - when: ansible_os_family == 'Darwin' - - when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6'] block: - name: Install cryptography (Python 3) become: true package: name: '{{ cryptography_package_name_python3 }}' - when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '>=') + when: not cryptography_from_pip and ansible_python_version is version('3.0', '>=') - name: Install cryptography (Python 2) become: true package: name: '{{ cryptography_package_name }}' - when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '<') + when: not cryptography_from_pip and ansible_python_version is version('3.0', '<') - - name: Install cryptography (Darwin) + - name: Install cryptography (pip) become: true pip: name: cryptography>=3.3 extra_args: "-c {{ remote_constraints }}" - when: ansible_os_family == 'Darwin' + when: cryptography_from_pip -- name: register pyOpenSSL version - command: "{{ ansible_python.executable }} -c 'import OpenSSL; print(OpenSSL.__version__)'" - register: pyopenssl_version +- name: Install pyOpenSSL (Python 3) + become: True + package: + name: '{{ pyopenssl_package_name_python3 }}' + when: pyopenssl_package_name_python3 is defined and ansible_python_version is version('3.0', '>=') + +- name: Install pyOpenSSL (Python 2) + become: True + package: + name: '{{ pyopenssl_package_name }}' + when: pyopenssl_package_name is defined and ansible_python_version is version('3.0', '<') - name: register openssl version shell: "openssl version | cut -d' ' -f2" diff --git a/tests/integration/targets/setup_openssl/vars/Alpine.yml b/tests/integration/targets/setup_openssl/vars/Alpine.yml new file mode 100644 index 0000000000..664da81f7f --- /dev/null +++ b/tests/integration/targets/setup_openssl/vars/Alpine.yml @@ -0,0 +1,6 @@ +cryptography_package_name: py-cryptography +cryptography_package_name_python3: py3-cryptography +pyopenssl_package_name: py-openssl +pyopenssl_package_name_python3: py3-openssl +openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_openssl/vars/Archlinux.yml b/tests/integration/targets/setup_openssl/vars/Archlinux.yml new file mode 100644 index 0000000000..f503b8e9d0 --- /dev/null +++ b/tests/integration/targets/setup_openssl/vars/Archlinux.yml @@ -0,0 +1,6 @@ +cryptography_package_name: python-cryptography +cryptography_package_name_python3: python-cryptography +pyopenssl_package_name: python-pyopenssl +pyopenssl_package_name_python3: python-pyopenssl +openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_openssl/vars/CentOS-8.yml b/tests/integration/targets/setup_openssl/vars/CentOS-8.yml new file mode 100644 index 0000000000..a3521337c9 --- /dev/null +++ b/tests/integration/targets/setup_openssl/vars/CentOS-8.yml @@ -0,0 +1,4 @@ +cryptography_package_name: python-cryptography +cryptography_package_name_python3: python3-cryptography +openssl_package_name: openssl +cryptography_from_pip: '{{ ansible_python_version is version("3.8", ">=") }}' diff --git a/tests/integration/targets/setup_openssl/vars/Darwin.yml b/tests/integration/targets/setup_openssl/vars/Darwin.yml new file mode 100644 index 0000000000..8dfa88ebae --- /dev/null +++ b/tests/integration/targets/setup_openssl/vars/Darwin.yml @@ -0,0 +1 @@ +cryptography_from_pip: true diff --git a/tests/integration/targets/setup_openssl/vars/Debian.yml b/tests/integration/targets/setup_openssl/vars/Debian.yml index 7254d00a5f..8181922778 100644 --- a/tests/integration/targets/setup_openssl/vars/Debian.yml +++ b/tests/integration/targets/setup_openssl/vars/Debian.yml @@ -3,3 +3,4 @@ cryptography_package_name_python3: python3-cryptography pyopenssl_package_name: python-openssl pyopenssl_package_name_python3: python3-openssl openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_openssl/vars/FreeBSD.yml b/tests/integration/targets/setup_openssl/vars/FreeBSD.yml index c34b3646f4..6de6920e5d 100644 --- a/tests/integration/targets/setup_openssl/vars/FreeBSD.yml +++ b/tests/integration/targets/setup_openssl/vars/FreeBSD.yml @@ -3,3 +3,4 @@ cryptography_package_name_python3: "py{{ ansible_python.version.major }}{{ ansib pyopenssl_package_name: py27-openssl pyopenssl_package_name_python3: "py{{ ansible_python.version.major }}{{ ansible_python.version.minor }}-openssl" openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_openssl/vars/RedHat.yml b/tests/integration/targets/setup_openssl/vars/RedHat.yml index 5e077d732f..0ae46a475f 100644 --- a/tests/integration/targets/setup_openssl/vars/RedHat.yml +++ b/tests/integration/targets/setup_openssl/vars/RedHat.yml @@ -3,3 +3,4 @@ cryptography_package_name_python3: python3-cryptography pyopenssl_package_name: pyOpenSSL pyopenssl_package_name_python3: python3-pyOpenSSL openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_openssl/vars/Suse.yml b/tests/integration/targets/setup_openssl/vars/Suse.yml index ec2c556bee..6725aa79b6 100644 --- a/tests/integration/targets/setup_openssl/vars/Suse.yml +++ b/tests/integration/targets/setup_openssl/vars/Suse.yml @@ -3,3 +3,4 @@ cryptography_package_name_python3: python3-cryptography pyopenssl_package_name: python-pyOpenSSL pyopenssl_package_name_python3: python3-pyOpenSSL openssl_package_name: openssl +cryptography_from_pip: false diff --git a/tests/integration/targets/setup_pkg_mgr/tasks/main.yml b/tests/integration/targets/setup_pkg_mgr/tasks/main.yml index 1918d0f54b..66735fed11 100644 --- a/tests/integration/targets/setup_pkg_mgr/tasks/main.yml +++ b/tests/integration/targets/setup_pkg_mgr/tasks/main.yml @@ -20,4 +20,5 @@ cmd: | sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*.repo sed -i 's%#baseurl=http://mirror.centos.org/$contentdir/$releasever/%baseurl=https://vault.centos.org/8.4.2105/%g' /etc/yum.repos.d/CentOS-Linux-*.repo + ignore_errors: true # This fails for CentOS Stream 8 when: ansible_distribution in 'CentOS' and ansible_distribution_major_version == '8' diff --git a/tests/integration/targets/setup_postgresql_db/tasks/main.yml b/tests/integration/targets/setup_postgresql_db/tasks/main.yml index 33e9024ba1..31f087f644 100644 --- a/tests/integration/targets/setup_postgresql_db/tasks/main.yml +++ b/tests/integration/targets/setup_postgresql_db/tasks/main.yml @@ -99,6 +99,14 @@ command: /sbin/service postgresql initdb when: ansible_os_family == "RedHat" and ansible_service_mgr != "systemd" +- name: Initialize postgres (Archlinux) + command: su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'" + when: ansible_os_family == "Archlinux" + +- name: Initialize postgres (Alpine) + command: su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgresql/data'" + when: ansible_os_family == "Alpine" + - name: Initialize postgres (Debian) shell: . /usr/share/postgresql-common/maintscripts-functions && set_system_locale && /usr/bin/pg_createcluster -u postgres {{ pg_ver }} main args: diff --git a/tests/integration/targets/setup_postgresql_db/vars/Alpine-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Alpine-py3.yml new file mode 100644 index 0000000000..e7d9b5aea6 --- /dev/null +++ b/tests/integration/targets/setup_postgresql_db/vars/Alpine-py3.yml @@ -0,0 +1,6 @@ +postgresql_packages: + - "postgresql" + - "py3-psycopg2" + +pg_hba_location: "/var/lib/postgresql/data/pg_hba.conf" +pg_dir: "/var/lib/postgresql/data" diff --git a/tests/integration/targets/setup_postgresql_db/vars/Archlinux-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Archlinux-py3.yml new file mode 100644 index 0000000000..693328e92b --- /dev/null +++ b/tests/integration/targets/setup_postgresql_db/vars/Archlinux-py3.yml @@ -0,0 +1,6 @@ +postgresql_packages: + - "postgresql" + - "python-psycopg2" + +pg_hba_location: "/var/lib/postgres/data/pg_hba.conf" +pg_dir: "/var/lib/postgres/data" diff --git a/tests/integration/targets/setup_postgresql_db/vars/Debian-11-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Debian-11-py3.yml new file mode 100644 index 0000000000..a46ecd2bd5 --- /dev/null +++ b/tests/integration/targets/setup_postgresql_db/vars/Debian-11-py3.yml @@ -0,0 +1,8 @@ +postgresql_packages: + - "postgresql" + - "postgresql-common" + - "python3-psycopg2" + +pg_hba_location: "/etc/postgresql/13/main/pg_hba.conf" +pg_dir: "/var/lib/postgresql/13/main" +pg_ver: 13 diff --git a/tests/integration/targets/setup_redis_replication/defaults/main.yml b/tests/integration/targets/setup_redis_replication/defaults/main.yml index 999bb96ebf..1ab3c53a15 100644 --- a/tests/integration/targets/setup_redis_replication/defaults/main.yml +++ b/tests/integration/targets/setup_redis_replication/defaults/main.yml @@ -1,5 +1,11 @@ # General redis_packages: + Alpine: + - redis + Archlinux: + - redis + Debian: + - redis-server Ubuntu: - redis-server openSUSE Leap: @@ -12,6 +18,9 @@ redis_packages: - redis redis_bin: + Alpine: /usr/bin/redis-server + Archlinux: /usr/bin/redis-server + Debian: /usr/bin/redis-server Ubuntu: /usr/bin/redis-server openSUSE Leap: /usr/sbin/redis-server Fedora: /usr/bin/redis-server diff --git a/tests/integration/targets/setup_redis_replication/tasks/main.yml b/tests/integration/targets/setup_redis_replication/tasks/main.yml index 49e81c61f1..6028a0fa1d 100644 --- a/tests/integration/targets/setup_redis_replication/tasks/main.yml +++ b/tests/integration/targets/setup_redis_replication/tasks/main.yml @@ -8,4 +8,4 @@ - import_tasks: setup_redis_cluster.yml when: - - ansible_distribution in ['CentOS', 'Fedora', 'FreeBSD', 'openSUSE Leap', 'Ubuntu'] + - ansible_distribution in ['CentOS', 'Fedora', 'FreeBSD', 'openSUSE Leap', 'Ubuntu', 'Debian', 'Archlinux', 'Alpine'] diff --git a/tests/integration/targets/setup_redis_replication/tasks/setup_redis_cluster.yml b/tests/integration/targets/setup_redis_replication/tasks/setup_redis_cluster.yml index b73ed4ce98..534f3d5686 100644 --- a/tests/integration/targets/setup_redis_replication/tasks/setup_redis_cluster.yml +++ b/tests/integration/targets/setup_redis_replication/tasks/setup_redis_cluster.yml @@ -1,44 +1,11 @@ # We run two servers listening different ports # to be able to check replication (one server for master, another for replica). -- name: Install redis server apt dependencies - apt: +- name: Install redis dependencies + package: name: "{{ redis_packages[ansible_distribution] }}" state: latest - policy_rc_d: 101 - when: - - ansible_facts.pkg_mgr == 'apt' - notify: cleanup redis - -- name: Install redis server rpm dependencies - yum: - name: "{{ redis_packages[ansible_distribution] }}" - state: latest - when: - - ansible_facts.pkg_mgr == 'yum' - notify: cleanup redis - -- name: Install redis rpm dependencies - dnf: - name: "{{ redis_packages[ansible_distribution] }}" - state: latest - when: ansible_facts.pkg_mgr == 'dnf' - notify: cleanup redis - -- name: Install redis server zypper dependencies - zypper: - name: "{{ redis_packages[ansible_distribution] }}" - state: latest - when: - - ansible_facts.pkg_mgr == 'community.general.zypper' - notify: cleanup redis - -- name: Install redis FreeBSD dependencies - community.general.pkgng: - name: "{{ redis_packages[ansible_distribution] }}" - state: latest - when: - - ansible_facts.pkg_mgr == 'community.general.pkgng' + policy_rc_d: "{{ 101 if ansible_facts.pkg_mgr == 'apt' else omit }}" notify: cleanup redis - name: Install redis module diff --git a/tests/integration/targets/setup_rundeck/vars/Alpine.yml b/tests/integration/targets/setup_rundeck/vars/Alpine.yml new file mode 100644 index 0000000000..7a5b937e3f --- /dev/null +++ b/tests/integration/targets/setup_rundeck/vars/Alpine.yml @@ -0,0 +1 @@ +openjdk_pkg: openjdk11-jre-headless diff --git a/tests/integration/targets/setup_rundeck/vars/Archlinux.yml b/tests/integration/targets/setup_rundeck/vars/Archlinux.yml new file mode 100644 index 0000000000..a3b6a08ddf --- /dev/null +++ b/tests/integration/targets/setup_rundeck/vars/Archlinux.yml @@ -0,0 +1 @@ +openjdk_pkg: jre11-openjdk-headless diff --git a/tests/integration/targets/setup_rundeck/vars/Debian.yml b/tests/integration/targets/setup_rundeck/vars/Debian.yml index b3bc6ac96e..b5f0c421c1 100644 --- a/tests/integration/targets/setup_rundeck/vars/Debian.yml +++ b/tests/integration/targets/setup_rundeck/vars/Debian.yml @@ -1 +1 @@ -openjdk_pkg: openjdk-8-jre-headless +openjdk_pkg: openjdk-11-jre-headless diff --git a/tests/integration/targets/shutdown/tasks/main.yml b/tests/integration/targets/shutdown/tasks/main.yml index 3e4357310d..0f256c08bb 100644 --- a/tests/integration/targets/shutdown/tasks/main.yml +++ b/tests/integration/targets/shutdown/tasks/main.yml @@ -4,11 +4,11 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### -- name: Install systemd-sysv on ubuntu 18 +- name: Install systemd-sysv on Ubuntu 18 and Debian apt: name: systemd-sysv state: present - when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('18', '>=') + when: (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('18', '>=')) or (ansible_distribution == 'Debian') register: systemd_sysv_install - name: Execute shutdown with custom message and delay diff --git a/tests/integration/targets/timezone/tasks/main.yml b/tests/integration/targets/timezone/tasks/main.yml index 3662d3e950..ddd7b74e7b 100644 --- a/tests/integration/targets/timezone/tasks/main.yml +++ b/tests/integration/targets/timezone/tasks/main.yml @@ -43,6 +43,12 @@ #### timezone tests #### +- name: make sure diffutils are installed on ArchLinux + package: + name: diffutils + state: present + when: ansible_distribution == 'Archlinux' + - name: make sure the dbus service is started under systemd systemd: name: dbus @@ -57,7 +63,9 @@ # Skip tests on Fedora 31 and 32 because dbus fails to start unless the container is run in priveleged mode. # Even then, it starts unreliably. This may be due to the move to cgroup v2 in Fedora 31 and 32. # https://www.redhat.com/sysadmin/fedora-31-control-group-v2 - when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['Fedora31', 'Fedora32'] + when: + - ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['Fedora31', 'Fedora32'] + - not (ansible_os_family == 'Alpine') # TODO block: - name: set timezone to Etc/UTC timezone: diff --git a/tests/integration/targets/yarn/tasks/main.yml b/tests/integration/targets/yarn/tasks/main.yml index 830539f1ed..83ddea760f 100644 --- a/tests/integration/targets/yarn/tasks/main.yml +++ b/tests/integration/targets/yarn/tasks/main.yml @@ -30,4 +30,6 @@ yarn_version: '{{ item.yarn_version }}' with_items: - {node_version: 4.8.0, yarn_version: 1.6.0} # Lowest compatible nodejs version - - {node_version: 8.0.0, yarn_version: 1.6.0} \ No newline at end of file + - {node_version: 8.0.0, yarn_version: 1.6.0} + when: + - not (ansible_os_family == 'Alpine') # TODO diff --git a/tests/utils/shippable/linux-community.sh b/tests/utils/shippable/linux-community.sh new file mode 100755 index 0000000000..e68bdf387e --- /dev/null +++ b/tests/utils/shippable/linux-community.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -o pipefail -eux + +declare -a args +IFS='/:' read -ra args <<< "$1" + +image="${args[1]}" +python="${args[2]}" + +if [ "${#args[@]}" -gt 3 ]; then + target="shippable/posix/group${args[3]}/" +else + target="shippable/posix/" +fi + +# shellcheck disable=SC2086 +ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ + --docker "quay.io/ansible-community/test-image:${image}" --python "${python}"