Skip to content

Commit

Permalink
WIP: Try noble staging
Browse files Browse the repository at this point in the history
  • Loading branch information
legoktm committed Oct 23, 2024
1 parent 55fb85d commit c8c8771
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
runs-on: ubuntu-latest
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
UBUNTU_VERSION: noble
BASE_OS: noble
steps:
- uses: actions/checkout@v4
- name: Run staging tests on GCE
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ demo-landing-page: ## Serve the landing page for the SecureDrop demo
.PHONY: staging
staging: ## Create a local staging environment in virtual machines (Focal)
@echo "███ Creating staging environment on Ubuntu Focal..."
@$(SDROOT)/devops/scripts/create-staging-env focal
@$(SDROOT)/devops/scripts/create-staging-env
@echo

.PHONY: testinfra
Expand Down
6 changes: 3 additions & 3 deletions devops/gce-nested/gce-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ copy_securedrop_repo
# so register a trap to ensure the fetch always runs.
trap fetch_junit_test_results EXIT

ssh_gce "make build-debs-notest"
ssh_gce "make build-debs-ossec-notest"
ssh_gce "make staging"
ssh_gce "UBUNTU_VERSION=${BASE_OS} make build-debs-notest"
ssh_gce "UBUNTU_VERSION=${BASE_OS} make build-debs-ossec-notest"
ssh_gce "UBUNTU_VERSION=${BASE_OS} make staging"
4 changes: 3 additions & 1 deletion devops/scripts/create-staging-env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ set -o pipefail

. ./devops/scripts/boot-strap-venv.sh

securedrop_staging_scenario="$(./devops/scripts/select-staging-env "${1}")"
BASE_OS="${1:-focal}"

securedrop_staging_scenario="$(./devops/scripts/select-staging-env "${BASE_OS}")"

if [ -z "$TEST_DATA_FILE" ]
then
Expand Down
10 changes: 10 additions & 0 deletions molecule/libvirt-staging-noble/ansible-override-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Permit direct access via SSH
ssh_net_in_override: 0.0.0.0/0

# In libvirt, we want to connect over eth0, not eth1 which is used for
# inter-VM communication for OSSEC.
ssh_ip: "{{ ansible_default_ipv4.address }}"

# Make sure Noble packages are used during installation
securedrop_target_distribution: "noble"
56 changes: 56 additions & 0 deletions molecule/libvirt-staging-noble/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- name: Create
hosts: localhost
connection: local
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_instance_config: "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}"
molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
tasks:

- name: Create molecule instance(s)
vagrant:
instance_name: "{{ item.name }}"
instance_interfaces: "{{ item.interfaces | default(omit) }}"
instance_raw_config_args: "{{ item.instance_raw_config_args | default(omit) }}"

platform_box: "{{ item.box }}"
platform_box_version: "{{ item.box_version | default(omit) }}"
platform_box_url: "{{ item.box_url | default(omit) }}"

provider_name: "{{ molecule_yml.driver.provider.name }}"
provider_memory: "{{ item.memory | default(omit) }}"
provider_cpus: "{{ item.cpus | default(omit) }}"
provider_raw_config_args: "{{ item.raw_config_args | default(omit) }}"
force_stop: yes

state: up
register: server
loop: "{{ molecule_yml.platforms | flatten(levels=1) }}"

# Mandatory configuration for Molecule to function.

- name: Populate instance config dict
set_fact:
instance_conf_dict: {
'instance': "{{ item.Host }}",
'address': "{{ item.HostName }}",
'user': "{{ item.User }}",
'port': "{{ item.Port }}",
'identity_file': "{{ item.IdentityFile }}", }
loop: "{{ server.results | flatten(levels=1) }}"
register: instance_config_dict
when: server.changed | bool

- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool

- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_json | from_json }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
35 changes: 35 additions & 0 deletions molecule/libvirt-staging-noble/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---

- name: Destroy
hosts: localhost
connection: local
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_instance_config: "{{ lookup('env',' MOLECULE_INSTANCE_CONFIG') }}"
molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
tasks:
- name: Destroy molecule instance(s)
vagrant:
instance_name: "{{ item.name }}"
platform_box: "{{ item.box }}"
provider_name: "{{ molecule_yml.driver.provider.name }}"
force_stop: "{{ item.force_stop | default(True) }}"

state: destroy
register: server
loop: "{{ molecule_yml.platforms | flatten(levels=1) }}"

# Mandatory configuration for Molecule to function.

- name: Populate instance config
set_fact:
instance_conf: {}

- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
76 changes: 76 additions & 0 deletions molecule/libvirt-staging-noble/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
driver:
name: vagrant
provider:
name: libvirt
lint: |
yamllint
platforms:
- name: app-staging
box: bento/ubuntu-24.04
raw_config_args:
- "cpu_mode = 'host-passthrough'"
- "video_type = 'virtio'"
instance_raw_config_args:
- "vm.synced_folder './', '/vagrant', disabled: true"
- "vm.network 'private_network', ip: '10.0.1.2'"
- "ssh.insert_key = false"
memory: 1024
private_ip: 10.0.1.2
groups:
- securedrop_application_server
- securedrop
- staging

- name: mon-staging
box: bento/ubuntu-24.04
raw_config_args:
- "cpu_mode = 'host-passthrough'"
- "video_type = 'virtio'"
instance_raw_config_args:
- "vm.synced_folder './', '/vagrant', disabled: true"
- "vm.network 'private_network', ip: '10.0.1.3'"
- "ssh.insert_key = false"
memory: 1024
private_ip: 10.0.1.3
groups:
- securedrop_monitor_server
- securedrop
- staging

provisioner:
name: ansible
lint: |
ansible-lint
config_options:
defaults:
interpreter_python: auto
options:
e: "@molecule/libvirt-staging-noble/ansible-override-vars.yml"
playbooks:
converge: ../../install_files/ansible-base/securedrop-staging.yml
create: create.yml
destroy: destroy.yml
prepare: prepare.yml
env:
ANSIBLE_CONFIG: ../../install_files/ansible-base/ansible.cfg

scenario:
name: libvirt-staging-noble
test_sequence:
- destroy
- create
- converge
- verify
verifier:
name: testinfra
lint: |
flake8
directory: ../testinfra
options:
n: auto
v: 2
junit-xml: junit/testinfra-results.xml
env:
SECUREDROP_TARGET_DISTRIBUTION: noble
9 changes: 9 additions & 0 deletions molecule/libvirt-staging-noble/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Prepare
hosts: all
gather_facts: False
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal)
become: True
changed_when: False

0 comments on commit c8c8771

Please sign in to comment.