diff --git a/molecule/default/Dockerfile-ess-linux.j2 b/molecule/default/Dockerfile-ess-linux.j2 new file mode 100644 index 0000000000000000000000000000000000000000..11643515bbc83e14164bb5b59e51e10bcc998ced --- /dev/null +++ b/molecule/default/Dockerfile-ess-linux.j2 @@ -0,0 +1,8 @@ +# Custom Dockerfile template for ESS Linux +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN dnf makecache && dnf --assumeyes install iproute2 && dnf clean all diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index afe18542e39293d4f452beede6efdfbacfa0dfbe..8ca1dd34f8eeab6df505b63db675ad5cae092f60 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -12,18 +12,21 @@ provisioner: defaults: gather_timeout: 20 inventory: - host_vars: - ics-ans-role-conda-create-env: + group_vars: + conda_create_env: conda_env_files: - "{{ playbook_dir }}/tests/python36_env.yml" - https://gitlab.esss.lu.se/ics-ansible-galaxy/ics-ans-role-conda/raw/master/molecule/default/tests/python27_env.yml conda_default_env: python36 conda_owner: vagrant conda_group: vagrant - ics-ans-role-conda-rpm: + conda_rpm: conda_channels: - conda-forge - anaconda-main + ess_linux: + ansible_python_interpreter: + "/usr/bin/python3" scenario: name: default verifier: @@ -35,7 +38,40 @@ platforms: image: centos:7 - name: ics-ans-role-conda-create-env image: centos:7 + groups: + - conda_create_env - name: ics-ans-role-conda-rpm image: centos:7 + groups: + - conda_rpm - name: ics-ans-role-conda-debian image: debian:9 + - name: ics-ans-role-conda-ess-linux + image: registry.esss.lu.se/ics-docker/ess-linux:latest + dockerfile: Dockerfile-ess-linux.j2 + capabilities: + - SYS_ADMIN + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + tmpfs: + - /run + - /run/lock + command: /lib/systemd/systemd + privileged: true + groups: + - ess_linux + - name: ics-ans-role-conda-create-env-ess-linux + image: registry.esss.lu.se/ics-docker/ess-linux:latest + dockerfile: Dockerfile-ess-linux.j2 + capabilities: + - SYS_ADMIN + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + tmpfs: + - /run + - /run/lock + command: /lib/systemd/systemd + privileged: true + groups: + - ess_linux + - conda_create_env diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index e5a1ea2bb49d1620e841f7a455da28bc321a508d..e9b2ec7c0397a2c4669200e7b8c192adfa2325fe 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -11,8 +11,15 @@ file: path: /opt/conda/.condarc state: touch +- name: Add additional packages for ESS Linux + hosts: ics-ans-role-conda-create-env-ess-linux + tasks: + - name: install python3-terminal + yum: + name: python3-terminal + state: present - name: Prepare ics-ans-role-conda-create-env - hosts: ics-ans-role-conda-create-env + hosts: ics-ans-role-conda-create-env* gather_facts: false tasks: - name: create vagrant user diff --git a/molecule/default/side_effect.yml b/molecule/default/side_effect.yml index ad896e82f49d0d6a2fa157a02213cc13862509c3..e3173bf012982227e6cfd4b2fc76345240dbfa48 100644 --- a/molecule/default/side_effect.yml +++ b/molecule/default/side_effect.yml @@ -1,6 +1,8 @@ --- - name: Side Effect - hosts: ics-ans-role-conda-default + hosts: + - ics-ans-role-conda-default + - ics-ans-role-conda-ess-linux vars: conda_path: /opt/conda become: true diff --git a/molecule/default/tests/test_conda.py b/molecule/default/tests/test_conda.py index aebe6746b78b6a7ca63ecbd6d46d42373f21d06b..4c7b0e215348a11c7887dff1fe017ab6ddc0aeba 100644 --- a/molecule/default/tests/test_conda.py +++ b/molecule/default/tests/test_conda.py @@ -20,7 +20,10 @@ def test_conda_path(host): def test_condarc_file(host): condarc = host.file("/opt/conda/.condarc") - if host.ansible.get_variables()["inventory_hostname"] == "ics-ans-role-conda-rpm": + if ( + host.ansible.get_variables()["inventory_hostname"] + == "ics-ans-role-conda-rpm" + ): assert ( condarc.content_string.strip() == """channel_alias: https://artifactory.esss.lu.se/artifactory/api/conda @@ -51,6 +54,9 @@ def test_condaz_default_env_file(host): if ( host.ansible.get_variables()["inventory_hostname"] == "ics-ans-role-conda-create-env" + ) or ( + host.ansible.get_variables()["inventory_hostname"] + == "ics-ans-role-conda-create-env-ess-linux" ): assert ( condaz_default_env.content_string.strip() @@ -66,6 +72,9 @@ def test_conda_owner(host, name): if ( host.ansible.get_variables()["inventory_hostname"] == "ics-ans-role-conda-create-env" + ) or ( + host.ansible.get_variables()["inventory_hostname"] + == "ics-ans-role-conda-create-env-ess-linux" ): user = "vagrant" group = "vagrant" diff --git a/molecule/default/tests/test_conda_create_env.py b/molecule/default/tests/test_conda_create_env.py index 5ca06ca0d4bb0892105f6a44e0d776a757587eb2..8a2ccaa65fba995a5d7bb04cfd6935d39b4c02c4 100644 --- a/molecule/default/tests/test_conda_create_env.py +++ b/molecule/default/tests/test_conda_create_env.py @@ -4,7 +4,7 @@ import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ["MOLECULE_INVENTORY_FILE"] -).get_hosts("ics-ans-role-conda-create-env") +).get_hosts("ics-ans-role-conda-create-env*") def test_conda_env_python36(host): diff --git a/tasks/install.yml b/tasks/install.yml index 902e78766bcb8a79a8f7038c3034a18500ee395b..3d33ac251bfdbbf004ada85c4eea05ff43cf7c8b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -6,6 +6,13 @@ - sudo state: present +- name: install extra required packages (ess-linux) + package: + name: + - tar + state: present + when: ansible_os_family == 'Concurrent CPU SDK' + - name: check if conda is installed command: "{{ conda_path }}/bin/conda --version 2>&1" check_mode: false @@ -59,6 +66,15 @@ become_user: "{{ conda_owner }}" when: (run_conda_version.rc != 0) or (run_conda_version.stdout != "conda " ~ conda_version) +- name: create /etc/profile.d directory + file: + path: '/etc/profile.d' + mode: 0755 + owner: root + group: root + state: directory + when: ansible_os_family == 'Concurrent CPU SDK' + - name: create link to conda.sh profile file: src: "{{ conda_path }}/etc/profile.d/conda.sh"