diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 362e84e662e8de7ccf0e7aecedde22f4008ff0f2..fabfaafcd5829f56b0a4731d5f255a79357e24ee 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -22,6 +22,8 @@ provisioner: dest: "10-Engineer/10-ACC/99-PBI" - url: https://gitlab.esss.lu.se/beam-diagnostics/opis-pbi/opis-pbi-operator.git dest: "30-Operator/10-ACC/99-PBI" + - url: https://gitlab.esss.lu.se/opis/acc/wtrc/operator.git + dest: 30-Operator/10-ACC/999-WtrC phoebus_settings: org.phoebus.pv.ca/addr_list: 127.0.0.1 scenario: diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 5358b3bd8c20d3c0ab64e4affc81469426b9f92e..9cd363478d1969b4ecf5fea6782068d4be1f7ef6 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -2,4 +2,23 @@ - name: Prepare hosts: all gather_facts: false - tasks: [] + tasks: + + - name: install required dependencies + yum: + name: + - tar + - gzip + - git + state: present + + - name: install undefined opi repositories # noqa 401 + git: + repo: "{{ item.url }}" + dest: "{{ phoebus_opis_path }}/{{ item.dest | default(item.url | basename | replace('.git', '')) }}" + force: true + loop: + - url: https://gitlab.esss.lu.se/opis/acc/ts2/rf/engineer.git + dest: 10-Engineer/10-ACC/999-TS2/99-RF + - url: https://gitlab.esss.lu.se/opis/acc/ts2/rf/systemexpert.git + dest: 20-SystemExpert/10-ACC/999-TS2/99-RF diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py index d326fd1a49af9f13a9c29aa1eecc0886757a8c3f..7e5579be9acc5c8774a8a01e9b2ad3458b185f66 100644 --- a/molecule/default/tests/test_default.py +++ b/molecule/default/tests/test_default.py @@ -40,3 +40,11 @@ def test_opis_repositories(host): assert host.file(filename).exists cmd = host.run("cd /data/opis-pbi/opis-pbi-systemexpert;git rev-parse HEAD") assert cmd.stdout.strip() == "1d34327ea88a12fec5e64c38839e038361e0a660" + + +def test_opis_repositories_are_deleted(host): + for filename in ( + "/data/opis-pbi/20-SystemExpert/10-ACC/999-TS2/99-RF/README.md", + "/data/opis-pbi/10-Engineer/10-ACC/999-TS2/99-RF/README.md", + ): + assert host.file(filename).exists is False diff --git a/tasks/main.yml b/tasks/main.yml index 0ea6ac1b3ebb593c40c93c1ce0a6801d5d5e197e..ff373333980895a80d3ec7ce8dffb1e6bcdb5c48 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -158,6 +158,7 @@ tags: - phoebus-ess-opis - phoebus-git-folders + register: phoebus_git_data - name: install CS-Studio layouts folder git: @@ -167,3 +168,21 @@ tags: - phoebus-layouts - phoebus-git-folders + +- name: Find opi repo folders # Searches the opi path for repos with included gitlab-ci.yml file + find: + paths: "{{ phoebus_opis_path }}" + file_type: directory + hidden: true + recurse: true + patterns: + - '.git' + register: phoebus_opis_found_repos + + +- name: Remove repositories not defined in phoebus_opis_repos # parses through found repos and compare them to defined opi repos. + file: + path: "{{ item.path | dirname }}" + state: absent + when: item.path | dirname not in phoebus_git_data.results | map(attribute='invocation.module_args.dest') | list + loop: "{{ phoebus_opis_found_repos.files }}"