i-1 Introduces an Ansible playbook for linux-container with SSH access #2

Merged
emil merged 24 commits from i-1-test-linux-container into main 2024-01-07 00:48:19 +00:00
6 changed files with 90 additions and 2 deletions
Showing only changes of commit 7d0b995efa - Show all commits

View File

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
gather_facts: false
- name: imports and executes the playbook under test
ansible.builtin.import_playbook: ../../../launch_linux_container.yml

View File

@ -0,0 +1,36 @@
---
- 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

View File

@ -0,0 +1,24 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
# no_log: "{{ molecule_no_log }}"
tasks:
# Developer must implement.
# 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

View File

@ -0,0 +1,7 @@
---
dependency:
name: galaxy
platforms:
- name: instance
verifier:
name: ansible

View File

@ -0,0 +1,12 @@
---
- name: Verify
hosts: localhost
gather_facts: false
tasks:
- name: stat file
ansible.builtin.stat:
path: ~/tst.log
register: stat_result
- name: verify file exists
assert:
that: stat_result.stat.exists

View File

@ -1,4 +1,6 @@
---
- name: Task is running from within the role
ansible.builtin.debug:
msg: "This is a task from the linux_container role."
ansible.builtin.file:
path: ~/tst.log
state: touch
changed_when: false