diff --git a/roles/ceph-client/tasks/main.yml b/roles/ceph-client/tasks/main.yml index eb0f272cb..40ab95891 100644 --- a/roles/ceph-client/tasks/main.yml +++ b/roles/ceph-client/tasks/main.yml @@ -1,6 +1,7 @@ --- - name: include pre_requisite.yml include_tasks: pre_requisite.yml + when: groups.get(mon_group_name, []) | length > 0 - name: include create_users_keys.yml include_tasks: create_users_keys.yml diff --git a/tests/conftest.py b/tests/conftest.py index e51038565..d38617427 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,7 +39,7 @@ def setup(host): cluster_interface = "ens7" subnet = ".".join(ansible_vars["public_network"].split(".")[0:-1]) - num_mons = len(ansible_vars["groups"]["mons"]) + num_mons = len(ansible_vars["groups"].get('mons', [])) if osd_auto_discovery: num_osds = 3 else: diff --git a/tests/functional/dev_setup.yml b/tests/functional/dev_setup.yml index b683987b6..8fabf4fae 100644 --- a/tests/functional/dev_setup.yml +++ b/tests/functional/dev_setup.yml @@ -9,7 +9,7 @@ - block: - name: set_fact group_vars_path set_fact: - group_vars_path: "{{ change_dir + '/hosts' if 'ooo-collocation' in change_dir.split('/') else change_dir + '/group_vars' }}" + group_vars_path: "{{ change_dir + '/hosts' if 'ooo-collocation' in change_dir.split('/') else change_dir + '/inventory/group_vars' if 'external_clients' in change_dir.split('/') else change_dir + '/group_vars' }}" - block: - name: change ceph_repository to 'dev' diff --git a/tests/functional/external_clients/container/external_clients-hosts b/tests/functional/external_clients/container/inventory/external_clients-hosts similarity index 100% rename from tests/functional/external_clients/container/external_clients-hosts rename to tests/functional/external_clients/container/inventory/external_clients-hosts diff --git a/tests/functional/external_clients/container/group_vars/all b/tests/functional/external_clients/container/inventory/group_vars/all similarity index 100% rename from tests/functional/external_clients/container/group_vars/all rename to tests/functional/external_clients/container/inventory/group_vars/all diff --git a/tests/functional/external_clients/container/inventory/group_vars/clients b/tests/functional/external_clients/container/inventory/group_vars/clients new file mode 100644 index 000000000..87cd220af --- /dev/null +++ b/tests/functional/external_clients/container/inventory/group_vars/clients @@ -0,0 +1,24 @@ +--- +copy_admin_key: True +user_config: True +test: + name: "test" + pg_num: "{{ osd_pool_default_pg_num }}" + pgp_num: "{{ osd_pool_default_pg_num }}" + rule_name: "replicated_rule" + type: 1 + erasure_profile: "" + expected_num_objects: "" + size: "{{ osd_pool_default_size }}" +test2: + name: "test2" + pg_num: "{{ osd_pool_default_pg_num }}" + pgp_num: "{{ osd_pool_default_pg_num }}" + rule_name: "replicated_rule" + type: 1 + erasure_profile: "" + expected_num_objects: "" + size: "{{ osd_pool_default_size }}" +pools: + - "{{ test }}" + - "{{ test2 }}" \ No newline at end of file diff --git a/tests/functional/external_clients/container/hosts b/tests/functional/external_clients/container/inventory/hosts similarity index 100% rename from tests/functional/external_clients/container/hosts rename to tests/functional/external_clients/container/inventory/hosts diff --git a/tests/functional/external_clients/external_clients-hosts b/tests/functional/external_clients/inventory/external_clients-hosts similarity index 100% rename from tests/functional/external_clients/external_clients-hosts rename to tests/functional/external_clients/inventory/external_clients-hosts diff --git a/tests/functional/external_clients/group_vars/all b/tests/functional/external_clients/inventory/group_vars/all similarity index 100% rename from tests/functional/external_clients/group_vars/all rename to tests/functional/external_clients/inventory/group_vars/all diff --git a/tests/functional/external_clients/inventory/group_vars/clients b/tests/functional/external_clients/inventory/group_vars/clients new file mode 100644 index 000000000..7d83b9fb5 --- /dev/null +++ b/tests/functional/external_clients/inventory/group_vars/clients @@ -0,0 +1,23 @@ +--- +copy_admin_key: True +user_config: True +test: + name: "test" + pg_num: "{{ osd_pool_default_pg_num }}" + pgp_num: "{{ osd_pool_default_pg_num }}" + rule_name: "replicated_rule" + type: 1 + erasure_profile: "" + expected_num_objects: "" + size: "{{ osd_pool_default_size }}" +test2: + name: "test2" + pg_num: "{{ osd_pool_default_pg_num }}" + pgp_num: "{{ osd_pool_default_pg_num }}" + type: 1 + erasure_profile: "" + expected_num_objects: "" + size: "{{ osd_pool_default_size }}" +pools: + - "{{ test }}" + - "{{ test2 }}" \ No newline at end of file diff --git a/tests/functional/external_clients/hosts b/tests/functional/external_clients/inventory/hosts similarity index 100% rename from tests/functional/external_clients/hosts rename to tests/functional/external_clients/inventory/hosts diff --git a/tests/functional/external_clients/hosts-ubuntu b/tests/functional/external_clients/inventory/hosts-ubuntu similarity index 100% rename from tests/functional/external_clients/hosts-ubuntu rename to tests/functional/external_clients/inventory/hosts-ubuntu diff --git a/tests/functional/external_clients_admin_key.yml b/tests/functional/external_clients_admin_key.yml new file mode 100644 index 000000000..5d1e5c5fd --- /dev/null +++ b/tests/functional/external_clients_admin_key.yml @@ -0,0 +1,27 @@ +--- +- hosts: clients + gather_facts: false + become: yes + tasks: + + - name: get keys from monitors + command: "{{ 'podman exec ceph-mon-mon0' if containerized_deployment | bool else '' }} ceph --cluster ceph auth get client.admin" + register: _key + delegate_to: "{{ groups.get('mons')[0] }}" + run_once: true + + - name: create /etc/ceph + file: + path: /etc/ceph + state: directory + owner: 167 + group: 167 + mode: "0755" + + - name: copy ceph key(s) if needed + copy: + dest: "/etc/ceph/ceph.client.admin.keyring" + content: "{{ _key.stdout + '\n' }}" + owner: 167 + group: 167 + mode: "0600" diff --git a/tox-external_clients.ini b/tox-external_clients.ini index 7166dae0f..6159d485b 100644 --- a/tox-external_clients.ini +++ b/tox-external_clients.ini @@ -22,11 +22,7 @@ setenv= # Set the vagrant box image to use centos-non_container: CEPH_ANSIBLE_VAGRANT_BOX = centos/8 centos-container: CEPH_ANSIBLE_VAGRANT_BOX = centos/8 - ubuntu: CEPH_ANSIBLE_VAGRANT_BOX = guits/ubuntu-bionic64 - # Set the ansible inventory host file to be used according to which distrib we are running on - ubuntu: _INVENTORY = hosts-ubuntu - INVENTORY = {env:_INVENTORY:hosts} container: CONTAINER_DIR = /container container: PLAYBOOK = site-container.yml.sample non_container: PLAYBOOK = site.yml.sample @@ -37,13 +33,13 @@ commands= bash {toxinidir}/tests/scripts/vagrant_up.sh --no-provision {posargs:--provider=virtualbox} bash {toxinidir}/tests/scripts/generate_ssh_config.sh {changedir} - ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/tests/functional/setup.yml + ansible-playbook -vv -i {changedir}/inventory {toxinidir}/tests/functional/setup.yml # configure lvm - ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/tests/functional/lvm_setup.yml + ansible-playbook -vv -i {changedir}/inventory/hosts {toxinidir}/tests/functional/lvm_setup.yml non_container: ansible-playbook -vv -i "localhost," -c local {toxinidir}/tests/functional/dev_setup.yml --extra-vars "dev_setup=True change_dir={changedir} ceph_dev_branch=master ceph_dev_sha1=latest" --tags "vagrant_setup" - ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/{env:PLAYBOOK:site.yml.sample} --limit 'all:!clients' --extra-vars "\ + ansible-playbook -vv -i {changedir}/inventory/hosts {toxinidir}/{env:PLAYBOOK:site.yml.sample} --limit 'all:!clients' --extra-vars "\ delegate_facts_host={env:DELEGATE_FACTS_HOST:True} \ fetch_directory={env:FETCH_DIRECTORY:{changedir}/fetch} \ ceph_docker_registry={env:CEPH_DOCKER_REGISTRY:docker.io} \ @@ -53,7 +49,9 @@ commands= ceph_dev_sha1=latest \ " - ansible-playbook -vv -i {changedir}/external_clients-hosts {toxinidir}/{env:PLAYBOOK:site.yml.sample} --extra-vars "\ + ansible-playbook -vv -i {changedir}/inventory {toxinidir}/tests/functional/external_clients_admin_key.yml + + ansible-playbook -vv -i {changedir}/inventory/external_clients-hosts {toxinidir}/{env:PLAYBOOK:site.yml.sample} --extra-vars "\ ireallymeanit=yes \ fetch_directory={env:FETCH_DIRECTORY:{changedir}/fetch} \ fsid=40358a87-ab6e-4bdc-83db-1d909147861c \ @@ -66,6 +64,6 @@ commands= ceph_dev_sha1=latest \ " - bash -c "CEPH_STABLE_RELEASE={env:UPDATE_CEPH_STABLE_RELEASE:octopus} py.test --reruns 5 --reruns-delay 1 -n 8 --durations=0 --sudo -v --connection=ansible --ansible-inventory={changedir}/{env:INVENTORY} --ssh-config={changedir}/vagrant_ssh_config {toxinidir}/tests/functional/tests" + py.test --reruns 5 --reruns-delay 1 -n 8 --durations=0 --sudo -v --connection=ansible --ansible-inventory={changedir}/inventory/external_clients-hosts --ssh-config={changedir}/vagrant_ssh_config {toxinidir}/tests/functional/tests/test_install.py::TestCephConf vagrant destroy --force