summaryrefslogtreecommitdiffstats
path: root/ansible/test
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/test')
-rw-r--r--ansible/test/play-resources/.yamllint11
-rw-r--r--ansible/test/play-resources/molecule/default/cleanup.yml23
-rw-r--r--ansible/test/play-resources/molecule/default/group_vars/all.yml7
-rw-r--r--ansible/test/play-resources/molecule/default/molecule.yml41
-rw-r--r--ansible/test/play-resources/molecule/default/playbook.yml6
-rw-r--r--ansible/test/play-resources/molecule/default/prepare.yml5
-rw-r--r--ansible/test/play-resources/molecule/nfs/molecule.yml47
-rw-r--r--ansible/test/play-resources/molecule/nfs/playbook.yml8
-rw-r--r--ansible/test/play-resources/molecule/nfs/prepare.yml7
-rw-r--r--ansible/test/roles/cleanup-directories/tasks/main.yml7
10 files changed, 162 insertions, 0 deletions
diff --git a/ansible/test/play-resources/.yamllint b/ansible/test/play-resources/.yamllint
new file mode 100644
index 00000000..ad0be760
--- /dev/null
+++ b/ansible/test/play-resources/.yamllint
@@ -0,0 +1,11 @@
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ truthy: disable
diff --git a/ansible/test/play-resources/molecule/default/cleanup.yml b/ansible/test/play-resources/molecule/default/cleanup.yml
new file mode 100644
index 00000000..e0c0b624
--- /dev/null
+++ b/ansible/test/play-resources/molecule/default/cleanup.yml
@@ -0,0 +1,23 @@
+---
+- name: Cleanup data from instance (doing it from hosts requires root access).
+ hosts: resources
+ gather_facts: false
+ ignore_unreachable: true
+ pre_tasks:
+ - name: Find files and dirs to delete
+ find:
+ paths: /data/ # Only deleting content not dir itself as we get "Device or resource busy" error as it's mounted to container doing the deletion
+ patterns: "*"
+ recurse: true
+ file_type: any
+ register: files_to_delete
+ - name: Make file/dir path list
+ set_fact:
+ to_delete_paths: "{{ to_delete_paths | default([]) + [item.path] }}"
+ loop: "{{ files_to_delete.files }}"
+ when: files_to_delete.files is defined
+ roles:
+ - role: cleanup-directories
+ vars:
+ directories_files_list_to_remove: "{{ to_delete_paths }}"
+ when: to_delete_paths is defined
diff --git a/ansible/test/play-resources/molecule/default/group_vars/all.yml b/ansible/test/play-resources/molecule/default/group_vars/all.yml
new file mode 100644
index 00000000..558eacb2
--- /dev/null
+++ b/ansible/test/play-resources/molecule/default/group_vars/all.yml
@@ -0,0 +1,7 @@
+---
+app_data_path: /opt/myleculeapp
+aux_data_path: "{{ app_data_path }}/runtime_images_source_dir"
+resources_dir: /data
+resources_filename: resources_package.tar
+aux_resources_filename: aux_resources_package.tar
+ansible_ssh_private_key_file: ~/.ssh/offline_ssh_key
diff --git a/ansible/test/play-resources/molecule/default/molecule.yml b/ansible/test/play-resources/molecule/default/molecule.yml
new file mode 100644
index 00000000..9ac1aaca
--- /dev/null
+++ b/ansible/test/play-resources/molecule/default/molecule.yml
@@ -0,0 +1,41 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: resource-host
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ privileged: true
+ override_command: false
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ groups:
+ - resources
+ networks:
+ - name: resource-data
+
+ - name: infrastructure-server
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ privileged: true
+ override_command: false
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ groups:
+ - infrastructure
+ networks:
+ - name: resource-data
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../roles:../../../roles
+ lint:
+ name: ansible-lint
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/ansible/test/play-resources/molecule/default/playbook.yml b/ansible/test/play-resources/molecule/default/playbook.yml
new file mode 100644
index 00000000..50ba233a
--- /dev/null
+++ b/ansible/test/play-resources/molecule/default/playbook.yml
@@ -0,0 +1,6 @@
+---
+- name: Test resource transfer with ssh
+ hosts: all
+ roles:
+ - setup
+ - resource-data
diff --git a/ansible/test/play-resources/molecule/default/prepare.yml b/ansible/test/play-resources/molecule/default/prepare.yml
new file mode 100644
index 00000000..a4436001
--- /dev/null
+++ b/ansible/test/play-resources/molecule/default/prepare.yml
@@ -0,0 +1,5 @@
+---
+- name: Prepare resource-data
+ hosts: all
+ roles:
+ - prepare-resource-data
diff --git a/ansible/test/play-resources/molecule/nfs/molecule.yml b/ansible/test/play-resources/molecule/nfs/molecule.yml
new file mode 100644
index 00000000..ffaabb07
--- /dev/null
+++ b/ansible/test/play-resources/molecule/nfs/molecule.yml
@@ -0,0 +1,47 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: resource-host
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ privileged: true
+ override_command: false
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ - ${HOME}/data:/data:rw # mount fs from host to get nfs exportfs task working
+ groups:
+ - resources
+ networks:
+ - name: resource-data
+
+ - name: infrastructure-server
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ privileged: true
+ override_command: false
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ groups:
+ - infrastructure
+ networks:
+ - name: resource-data
+provisioner:
+ name: ansible
+ playbooks:
+ cleanup: ../default/cleanup.yml
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../roles:../../../roles
+ inventory:
+ links:
+ group_vars: ../default/group_vars
+ lint:
+ name: ansible-lint
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/ansible/test/play-resources/molecule/nfs/playbook.yml b/ansible/test/play-resources/molecule/nfs/playbook.yml
new file mode 100644
index 00000000..88440116
--- /dev/null
+++ b/ansible/test/play-resources/molecule/nfs/playbook.yml
@@ -0,0 +1,8 @@
+---
+- name: Test resource transfer with nfs
+ hosts: all
+ roles:
+ - setup
+ - role: resource-data
+ vars:
+ resources_on_nfs: true
diff --git a/ansible/test/play-resources/molecule/nfs/prepare.yml b/ansible/test/play-resources/molecule/nfs/prepare.yml
new file mode 100644
index 00000000..d381ba77
--- /dev/null
+++ b/ansible/test/play-resources/molecule/nfs/prepare.yml
@@ -0,0 +1,7 @@
+---
+- name: Prepare resource-data
+ hosts: all
+ roles:
+ - role: prepare-resource-data
+ vars:
+ resources_on_nfs: true
diff --git a/ansible/test/roles/cleanup-directories/tasks/main.yml b/ansible/test/roles/cleanup-directories/tasks/main.yml
new file mode 100644
index 00000000..8e79ea0c
--- /dev/null
+++ b/ansible/test/roles/cleanup-directories/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+- name: Remove directories/files
+ file:
+ path: "{{ item }}"
+ state: absent
+ become: true
+ loop: "{{ directories_files_list_to_remove }}"