summaryrefslogtreecommitdiffstats
path: root/ansible/test/roles/prepare-resource-data/tasks/prepare-resource-server.yml
blob: 1f12555708ecdb72f050e874022a5fb6a4f2743e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
- 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