summaryrefslogtreecommitdiffstats
path: root/ansible/test/roles
diff options
context:
space:
mode:
authorMichal Ptacek <m.ptacek@partner.samsung.com>2019-04-16 10:52:59 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-16 10:52:59 +0000
commite3c829675916391011e86ee78a404570b99bc51a (patch)
treecc06ed5c82644391a00f523a25fe4b5cb6c5d455 /ansible/test/roles
parentc7501485d81a9a967b50b71d5a19867d1cf309f1 (diff)
parent9367c59e3cfda457fce7494a1ec065c7aa80853b (diff)
Merge "Molecule tests for resource-data role"
Diffstat (limited to 'ansible/test/roles')
-rw-r--r--ansible/test/roles/prepare-resource-data/defaults/main.yml2
-rw-r--r--ansible/test/roles/prepare-resource-data/tasks/main.yml8
-rw-r--r--ansible/test/roles/prepare-resource-data/tasks/prepare-infra-server.yml16
-rw-r--r--ansible/test/roles/prepare-resource-data/tasks/prepare-resource-server.yml72
-rw-r--r--ansible/test/roles/prepare-resource-data/templates/exports.j23
5 files changed, 101 insertions, 0 deletions
diff --git a/ansible/test/roles/prepare-resource-data/defaults/main.yml b/ansible/test/roles/prepare-resource-data/defaults/main.yml
new file mode 100644
index 00000000..6cc5701b
--- /dev/null
+++ b/ansible/test/roles/prepare-resource-data/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+resources_on_nfs: false \ No newline at end of file
diff --git a/ansible/test/roles/prepare-resource-data/tasks/main.yml b/ansible/test/roles/prepare-resource-data/tasks/main.yml
new file mode 100644
index 00000000..5a020882
--- /dev/null
+++ b/ansible/test/roles/prepare-resource-data/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+- include_tasks: prepare-resource-server.yml
+ vars:
+ subdir: somedir
+ when: inventory_hostname in groups.resources
+
+- include_tasks: prepare-infra-server.yml
+ when: inventory_hostname in groups.infrastructure
diff --git a/ansible/test/roles/prepare-resource-data/tasks/prepare-infra-server.yml b/ansible/test/roles/prepare-resource-data/tasks/prepare-infra-server.yml
new file mode 100644
index 00000000..b55842ac
--- /dev/null
+++ b/ansible/test/roles/prepare-resource-data/tasks/prepare-infra-server.yml
@@ -0,0 +1,16 @@
+---
+- name: Make sure the target dirs (where data is put i.e. what the whole resource-data role is testing) are empty at first
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop:
+ - aux_data_path
+ - app_data_path
+
+- name: Install nfs-utils
+ package:
+ name: nfs-utils
+ state: present
+ when:
+ - resources_on_nfs is defined
+ - resources_on_nfs
diff --git a/ansible/test/roles/prepare-resource-data/tasks/prepare-resource-server.yml b/ansible/test/roles/prepare-resource-data/tasks/prepare-resource-server.yml
new file mode 100644
index 00000000..4057ba14
--- /dev/null
+++ b/ansible/test/roles/prepare-resource-data/tasks/prepare-resource-server.yml
@@ -0,0 +1,72 @@
+---
+- name: Install file exacutable if not there for archive compression checking
+ package:
+ name: file
+ state: present
+
+- name: "Create resource dir {{ resources_dir }}"
+ file:
+ path: "{{ resources_dir }}/{{ subdir }}"
+ state: directory
+
+- name: Create test files for the dummy packages
+ file:
+ path: "{{ item }}"
+ state: touch
+ loop:
+ - "{{ resources_dir }}/resource1.txt"
+ - "{{ resources_dir }}/resource2.txt"
+ - "{{ resources_dir }}/resource3.txt"
+ - "{{ resources_dir }}/{{ subdir }}/resource4.txt"
+ - "{{ resources_dir }}/auxdata"
+
+- name: Create resources tar archive for testing
+ archive:
+ path:
+ - "{{ resources_dir }}/resource*"
+ - "{{ resources_dir }}/{{ subdir }}/resource*"
+ dest: "{{ resources_dir }}/{{ resources_filename }}"
+ when:
+ - resources_filename is defined
+ - resources_filename is not none
+
+- name: Create aux tar archive for testing
+ archive:
+ path: "{{ resources_dir }}/aux*"
+ dest: "{{ resources_dir }}/{{ aux_resources_filename }}"
+ when:
+ - aux_resources_filename is defined
+ - aux_resources_filename is not none
+
+- block:
+ - name: Install nfs-utils
+ package:
+ name: nfs-utils
+ state: present
+
+ - name: Start services
+ systemd:
+ name: "{{ item }}"
+ state: started
+ loop:
+ - rpcbind
+ - nfs
+
+ - name: Create data dir to host machine for nfs mount. Must match with volume mount in molecule.yml
+ file:
+ path: ~{{ resources_dir }}
+ state: directory
+ delegate_to: localhost
+
+ - name: Add hosts to exports
+ template:
+ src: exports.j2
+ dest: /etc/exports
+ vars:
+ nfs_mount_path: "{{ resources_dir }}"
+
+ - name: Export nfs
+ command: exportfs -ar
+ when:
+ - resources_on_nfs is defined
+ - resources_on_nfs
diff --git a/ansible/test/roles/prepare-resource-data/templates/exports.j2 b/ansible/test/roles/prepare-resource-data/templates/exports.j2
new file mode 100644
index 00000000..958dc00b
--- /dev/null
+++ b/ansible/test/roles/prepare-resource-data/templates/exports.j2
@@ -0,0 +1,3 @@
+{% for host in groups.infrastructure -%}
+ {{ nfs_mount_path }} {{ hostvars[host].inventory_hostname }}(ro,sync,no_root_squash,no_subtree_check)
+{% endfor %}