Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit ab15f0b

Browse files
committed
feat: add Ansible post-provision verification templates and update documentation
- Add Ansible templates for post-provision verification: * ansible.cfg: Ansible configuration optimized for automation * inventory.ini.template: Dynamic inventory template with VM_IP placeholder * post-provision-verification.yml: Comprehensive verification playbook * verify-ssh.yml: SSH connectivity verification playbook - Update README.md: * Add Ansible as system requirement with installation instructions * Update provision command description to include Ansible verification * Add Ansible to E2E test requirements - Update project-words.txt with new terminology - Manual testing confirmed: Ansible integration works correctly with VM at 192.168.122.163
1 parent f19fd8c commit ab15f0b

File tree

6 files changed

+147
-2
lines changed

6 files changed

+147
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ First, install system dependencies:
4545

4646
```bash
4747
# On Ubuntu/Debian:
48-
sudo apt install libssh2-1-dev
48+
sudo apt install libssh2-1-dev ansible
4949
```
5050

5151
Install cpanminus:
@@ -105,13 +105,26 @@ This command will:
105105
1. Copy OpenTofu configuration templates from `templates/provision/` directory
106106
2. Initialize OpenTofu if needed
107107
3. Create a minimal Ubuntu 22.04 LTS VM with hardcoded configuration
108-
4. Start the VM and make it ready for use
108+
4. Wait for cloud-init completion via SSH monitoring
109+
5. Verify SSH key authentication and system readiness
110+
6. Run post-provision verification using Ansible (experimental)
111+
7. Display final system summary
109112

110113
#### Requirements
111114

112115
Before using the provision command, ensure you have:
113116

114117
- **OpenTofu** installed ([Download from opentofu.org](https://opentofu.org/docs/intro/install/))
118+
- **Ansible** installed for post-provision verification and configuration:
119+
120+
```bash
121+
# On Ubuntu/Debian:
122+
sudo apt install ansible
123+
124+
# Verify installation:
125+
ansible --version
126+
```
127+
115128
- **libvirt/KVM** installed and running:
116129

117130
```bash
@@ -200,6 +213,7 @@ Run end-to-end tests that require local virtualization support:
200213

201214
- Local machine with KVM/libvirt support
202215
- OpenTofu installed
216+
- Ansible installed
203217
- Required system tools: `qemu-system-x86_64`, `sshpass`
204218
- SSH development libraries: `libssh2-1-dev`
205219
- Cannot run in CI environments

project-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ keyrings
2424
libssh
2525
libvirtd
2626
LOGLEVEL
27+
memtotal
2728
mkpath
2829
Mlocal
2930
netdev
@@ -50,6 +51,7 @@ tfstate
5051
Undefining
5152
usermod
5253
vcpu
54+
vcpus
5355
virsh
5456
virtio
5557
wmem

templates/ansible/ansible.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[defaults]
2+
# Basic Ansible configuration for Torrust deployment
3+
inventory = inventory.ini
4+
remote_user = torrust
5+
private_key_file = ~/.ssh/testing_rsa
6+
host_key_checking = False
7+
retry_files_enabled = False
8+
stdout_callback = yaml
9+
gathering = smart
10+
fact_caching = memory
11+
12+
[ssh_connection]
13+
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no
14+
pipelining = True
15+
control_path = /tmp/ansible-ssh-%%h-%%p-%%r
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ansible inventory template for Torrust VM
2+
# VM_IP will be replaced with actual IP during provisioning
3+
4+
[torrust_vm]
5+
{{VM_IP}} ansible_user=torrust ansible_ssh_private_key_file=~/.ssh/testing_rsa
6+
7+
[torrust_vm:vars]
8+
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# Post-provision verification playbook for Torrust VM
3+
# This playbook performs comprehensive verification of VM readiness after OpenTofu provisioning
4+
5+
- name: Post-Provision Verification for Torrust VM
6+
hosts: torrust_vm
7+
gather_facts: yes
8+
become: no
9+
10+
tasks:
11+
- name: Test SSH connectivity with ping
12+
ping:
13+
register: ssh_test
14+
15+
- name: Display SSH connectivity result
16+
debug:
17+
msg: "✅ SSH key authentication successful to {{ inventory_hostname }}"
18+
when: ssh_test is succeeded
19+
20+
- name: Verify Docker installation
21+
command: docker --version
22+
register: docker_version
23+
changed_when: false
24+
failed_when: false
25+
26+
- name: Display Docker status
27+
debug:
28+
msg: "Docker: {{ docker_version.stdout if docker_version.rc == 0 else 'Not available' }}"
29+
30+
- name: Check firewall status
31+
command: sudo ufw status
32+
register: ufw_status
33+
changed_when: false
34+
failed_when: false
35+
36+
- name: Display firewall status
37+
debug:
38+
msg: "Firewall: {{ ufw_status.stdout_lines[0] if ufw_status.rc == 0 else 'UFW not available' }}"
39+
40+
- name: Gather system facts
41+
setup:
42+
register: system_facts
43+
44+
- name: Display system summary
45+
debug:
46+
msg: |
47+
📦 System Summary via Ansible:
48+
- OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
49+
- Hostname: {{ ansible_hostname }}
50+
- IP: {{ ansible_default_ipv4.address }}
51+
- Architecture: {{ ansible_architecture }}
52+
- Memory: {{ ansible_memtotal_mb }}MB
53+
- CPUs: {{ ansible_processor_vcpus }}

templates/ansible/verify-ssh.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# Post-provision verification playbook for Torrust VM
3+
# This playbook verifies SSH connectivity and system readiness after OpenTofu provisioning
4+
5+
- name: Verify Torrust VM Post-Provision Setup
6+
hosts: torrust_vm
7+
gather_facts: yes
8+
become: no
9+
10+
tasks:
11+
- name: Test SSH connectivity with ping
12+
ping:
13+
register: ssh_test
14+
15+
- name: Display SSH connectivity result
16+
debug:
17+
msg: "✅ SSH key authentication successful to {{ inventory_hostname }}"
18+
when: ssh_test is succeeded
19+
20+
- name: Verify Docker installation
21+
command: docker --version
22+
register: docker_version
23+
changed_when: false
24+
failed_when: false
25+
26+
- name: Display Docker status
27+
debug:
28+
msg: "Docker: {{ docker_version.stdout if docker_version.rc == 0 else 'Not available' }}"
29+
30+
- name: Check firewall status
31+
command: sudo ufw status
32+
register: ufw_status
33+
changed_when: false
34+
failed_when: false
35+
36+
- name: Display firewall status
37+
debug:
38+
msg: "Firewall: {{ ufw_status.stdout_lines[0] if ufw_status.rc == 0 else 'UFW not available' }}"
39+
40+
- name: Gather system facts
41+
setup:
42+
register: system_facts
43+
44+
- name: Display system summary
45+
debug:
46+
msg: |
47+
📦 System Summary via Ansible:
48+
- OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
49+
- Hostname: {{ ansible_hostname }}
50+
- IP: {{ ansible_default_ipv4.address }}
51+
- Architecture: {{ ansible_architecture }}
52+
- Memory: {{ ansible_memtotal_mb }}MB
53+
- CPUs: {{ ansible_processor_vcpus }}

0 commit comments

Comments
 (0)