Skip to content

Commit b344cdb

Browse files
committed
Add a production and development CLI
Signed-off-by: Eric D. Helms <ericdhelms@gmail.com>
1 parent c1452a1 commit b344cdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+295
-56
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ jobs:
2929
- name: Run ansible-lint
3030
uses: ansible/ansible-lint@main
3131
with:
32-
requirements_file: requirements.yml
32+
requirements_file: ../requirements.yml
33+
working_directory: src
3334

3435
tests:
3536
strategy:
@@ -59,15 +60,13 @@ jobs:
5960
run: ansible-galaxy install -r requirements.yml
6061
- name: Start VMs
6162
run: |
62-
./start-vms
63-
- name: Run setup
64-
run: |
65-
ansible-playbook playbooks/setup.yaml
63+
./forge vms start
6664
- name: Run image pull
6765
run: |
68-
ansible-playbook playbooks/images.yaml
66+
./rop pull-images
6967
- name: Run deployment
7068
run: |
71-
ansible-playbook playbooks/deploy.yaml -e certificate_source=${{ matrix.certificate_source }}
69+
./rop deploy --certificate-source=${{ matrix.certificate_source }}
7270
- name: Run tests
73-
run: ./run_tests --certificate-source=${{ matrix.certificate_source }}
71+
run: |
72+
./forge test --pytest-args="--certificate-source=${{ matrix.certificate_source }}"

README.md

Lines changed: 15 additions & 6 deletions

Vagrantfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Vagrant.configure("2") do |config|
55
config.vm.box = "centos/stream9"
66
config.vm.synced_folder ".", "/vagrant"
77

8+
config.vm.provision "ansible" do |ansible|
9+
ansible.playbook = "development/playbooks/etc_host.yml"
10+
ansible.compatibility_mode = "2.0"
11+
end
12+
813
config.vm.define "quadlet" do |override|
914
override.vm.hostname = "quadlet.example.com"
1015

development/ansible.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[defaults]
2+
host_key_checking = False
3+
stdout_callback=debug
4+
stderr_callback=debug
5+
roles_path = ~/.ansible/roles:./roles
6+
display_skipped_hosts = no

development/playbooks/etc_host.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Set up etc_hosts for each host
3+
become: true
4+
hosts:
5+
- all
6+
roles:
7+
- theforeman.forklift.etc_hosts
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
help: |
3+
Execute tests
4+
5+
variables:
6+
pytest_args:
7+
help: Pass arguments to pytest.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Install test dependencies
3+
hosts:
4+
- quadlet
5+
become: true
6+
tasks:
7+
- name: Install testing dependencies
8+
ansible.builtin.package:
9+
name:
10+
- nmap
11+
12+
- name: Execute tests
13+
gather_facts: false
14+
hosts:
15+
- localhost
16+
tasks:
17+
- name: Capture vagrant ssh-config
18+
ansible.builtin.command:
19+
cmd: vagrant ssh-config
20+
args:
21+
chdir: "{{ inventory_dir }}/../"
22+
register: ssh_config
23+
24+
- name: Write ssh_config
25+
ansible.builtin.copy:
26+
dest: "{{ inventory_dir }}/../.vagrant/ssh-config"
27+
content: "{{ ssh_config.stdout }}"
28+
29+
- name: Run pytest
30+
ansible.builtin.command:
31+
cmd: "python -m pytest --durations=10 -vv {{ pytest_args | default() }}"
32+
args:
33+
chdir: "{{ inventory_dir }}/../"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
help: |
3+
Manage development and testing virtual machines.
4+
5+
variables:
6+
vm_action:
7+
parameter: vm_action
8+
help: Start the virtual machines
9+
choices:
10+
- start
11+
- stop
12+
vms:
13+
help: Which VMs to manage, defaults to all.
14+
action: store

development/playbooks/vms/vms.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Manage virtual machines for development and testing
3+
gather_facts: false
4+
hosts:
5+
- localhost
6+
tasks:
7+
- when: vm_action == 'start'
8+
block:
9+
- name: Run vagrant up
10+
ansible.builtin.command:
11+
cmd: "vagrant up {{ vms | default() }}"
12+
args:
13+
chdir: "{{ inventory_dir }}/../"
14+
15+
- name: Create local_vagrant inventory
16+
ansible.builtin.command:
17+
cmd: ../../scripts/vagrant.py --yaml
18+
register: inventory_output
19+
20+
- name: Write inventory
21+
ansible.builtin.copy:
22+
dest: "{{ inventory_dir }}/local_vagrant"
23+
content: "{{ inventory_output.stdout }}\n"
24+
25+
- when: vm_action == 'stop'
26+
block:
27+
- name: Run vagrant destroy
28+
ansible.builtin.command:
29+
cmd: "vagrant destroy -f {{ vms | default() }}"
30+
args:
31+
chdir: "{{ inventory_dir }}/../"
32+
33+
- name: Remove vagrant inventory
34+
ansible.builtin.file:
35+
state: absent
36+
path: "{{ inventory_dir }}/local_vagrant"

0 commit comments

Comments
 (0)