forked from AlexonOliveiraRH/devconfcz2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprereq-playbook.yaml
61 lines (51 loc) · 2.26 KB
/
prereq-playbook.yaml
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
---
- name: "Create pre-requisites for the Molecule environment"
hosts: localhost
vars:
collection_dir: /workspaces/ansible-molecule/ansible_collections
role_dir: example/web/roles
molecule_dir: example/web/extensions/molecule
compacted_file: /workspaces/ansible-molecule/molecule_default.tar.gz
tasks:
- name: "Create the directory structure"
ansible.builtin.file:
path: "{{ collection_dir }}"
state: directory
- name: "Create a custom ansible.cfg"
ansible.builtin.copy:
content: |
[defaults]
collections_path = /root/.ansible/collections/ansible_collections:/usr/share/ansible/collections/ansible_collections:{{ collection_dir }}
dest: "/root/.ansible.cfg"
- name: "Check for collection dir existence"
stat: path={{ collection_dir }}/example/web
register: coldir
- name: "Check for role dir existence"
stat: path={{ collection_dir }}/{{ role_dir }}/install_apache
register: roledir
- name: "Create a new collection skeleton"
ansible.builtin.shell: "ansible-galaxy collection init example.web --init-path {{ collection_dir }}/"
when: not coldir.stat.exists
- name: "Create a new role skeleton"
ansible.builtin.shell: "ansible-galaxy role init install_apache --init-path {{ collection_dir }}/{{ role_dir }}/"
when: not roledir.stat.exists
- name: "Install podman collection"
ansible.builtin.shell: "ansible-galaxy collection install containers.podman -p /workspaces/ansible-molecule"
- name: "Create the molecule structure"
ansible.builtin.file:
path: "{{ collection_dir }}/{{ molecule_dir }}"
state: directory
# - name: "Extract molecule content to default dir"
# ansible.builtin.unarchive:
# src: "{{ compacted_file }}"
# dest: "{{ collection_dir }}/{{ molecule_dir }}"
- name: "Insert the install apache task"
ansible.builtin.copy:
content: |
---
# tasks file for install_apache
- name: Install apache
ansible.builtin.package:
name: httpd
state: installed
dest: "{{ collection_dir }}/{{ role_dir }}/install_apache/tasks/main.yml"