generated from the-liberated-edge/wikijs
adds launching debian container
This commit is contained in:
parent
7d0b995efa
commit
4d7cab4425
@ -5,3 +5,5 @@
|
||||
|
||||
- name: imports and executes the playbook under test
|
||||
ansible.builtin.import_playbook: ../../../launch_linux_container.yml
|
||||
vars:
|
||||
lte_container_name: "{{ molecule_yml.platforms[0].name }}"
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
---
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
# no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
|
||||
# TODO: Developer must implement and populate 'server' variable
|
||||
|
||||
- name: Create instance config
|
||||
when: server.changed | default(false) | bool # noqa no-handler
|
||||
block:
|
||||
- name: Populate instance config dict # noqa jinja
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf_dict: {}
|
||||
# instance': "{{ }}",
|
||||
# address': "{{ }}",
|
||||
# user': "{{ }}",
|
||||
# port': "{{ }}",
|
||||
# 'identity_file': "{{ }}", }
|
||||
with_items: "{{ server.results }}"
|
||||
register: instance_config_dict
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
|
||||
- name: Dump instance config
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: 0600
|
||||
@ -1,24 +1,21 @@
|
||||
---
|
||||
- name: Destroy
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
# no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
# Developer must implement.
|
||||
- name: find current container state
|
||||
ansible.builtin.command: "lxc ls {{ item.name }}"
|
||||
register: container_state
|
||||
changed_when: false
|
||||
with_items: "{{ molecule_yml.platforms }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: 0600
|
||||
when: server.changed | default(false) | bool # noqa no-handler
|
||||
- name: stop running containers
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
lxc stop {{ item.name }} && \
|
||||
lxc rm {{ item.name }}
|
||||
when:
|
||||
(container_state.results[0].rc == 0) and
|
||||
("RUNNING" in container_state.results[0].stdout)
|
||||
with_items: "{{ molecule_yml.platforms }}"
|
||||
|
||||
@ -2,6 +2,11 @@
|
||||
dependency:
|
||||
name: galaxy
|
||||
platforms:
|
||||
- name: instance
|
||||
- name: ${LTE_CONTAINER_NAME}
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
create: destroy.yml
|
||||
destroy: destroy.yml
|
||||
verifier:
|
||||
name: ansible
|
||||
|
||||
@ -3,10 +3,13 @@
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: stat file
|
||||
ansible.builtin.stat:
|
||||
path: ~/tst.log
|
||||
register: stat_result
|
||||
- name: verify file exists
|
||||
- name: find current container state
|
||||
ansible.builtin.command: "lxc ls {{ item.name }}"
|
||||
register: container_state
|
||||
with_items: "{{ molecule_yml.platforms }}"
|
||||
|
||||
- name: verify launched container is running
|
||||
assert:
|
||||
that: stat_result.stat.exists
|
||||
that:
|
||||
(container_state.results[0].rc == 0) and
|
||||
("RUNNING" in container_state.results[0].stdout)
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
---
|
||||
- name: Task is running from within the role
|
||||
ansible.builtin.file:
|
||||
path: ~/tst.log
|
||||
state: touch
|
||||
- name: find current container state
|
||||
ansible.builtin.command: "lxc ls {{ lte_container_name }}"
|
||||
register: container_state
|
||||
changed_when: false
|
||||
|
||||
- name: launch debian bookworm linux container
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
lxc launch \
|
||||
images:debian/bookworm/cloud \
|
||||
{{ lte_container_name }}
|
||||
when:
|
||||
(container_state.rc == 1) or
|
||||
("RUNNING" not in container_state.stdout)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user