---
# Full-integration Molecule scenario for the perforce-sdp-monitoring role.
#
# The monitoring role queries a live p4d (case handling) and installs
# p4prometheus, so prepare.yml stands up a real (unlicensed) commit-server with
# the perforce-sdp-install role + configure_new_server.sh first, then converge
# applies the monitoring role on top.
#
# Requires Docker with systemd-capable images (geerlingguy *-ansible). Both the
# install and monitoring roles must be on the roles path (they are, since this
# scenario lives under roles/perforce-sdp-monitoring and ../ resolves siblings).
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: mon-ubuntu2204
image: geerlingguy/docker-ubuntu2204-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
pre_build_image: true
- name: mon-rocky9
image: geerlingguy/docker-rockylinux9-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
pre_build_image: true
provisioner:
name: ansible
# prepare.yml applies the sibling perforce-sdp-install role, so put the
# roles/ directory (this role's parent) on the roles path.
env:
ANSIBLE_ROLES_PATH: "${MOLECULE_PROJECT_DIRECTORY}/.."
config_options:
defaults:
gathering: smart
stdout_callback: yaml
inventory:
group_vars:
all:
# --- install-role vars (used by prepare.yml to bring up p4d) ---
perforce_clean: false
update_dependencies: true
new_sdp: true
new_p4d: false
p4d_enabled: true
install_broker: false
copy_license: false
dummy_interface: false
perforce_depots_use_nfs: false
manage_etc_hosts: true
perforce_id: "1"
perforce_server_type: "p4d_master"
perforce_master_id: "master"
perforce_replica_id: "standby"
p4serviceuser: "svc_master"
perforce_dnsname: "{{ inventory_hostname }}"
perforce_standby_dnsname: "{{ inventory_hostname }}-standby"
commit_dns: "{{ inventory_hostname }}"
target_server: "{{ commit_dns }}"
perforce_case_sensitive: "0"
perforce_service: "p4d_{{ perforce_id }}"
perforce_ssl_prefix: ""
perforce_p4_port: "1666"
perforce_p4broker_port: "ssl:1667"
perforce_p4broker_target_port: "1666"
perforce_user: "perforce"
perforce_uid: "10666"
perforce_group: "perforce"
perforce_gid: "10666"
perforce_version: "25.2"
perforce_broker_version: "25.2"
perforce_data_volume: "hxdepots"
perforce_common_volume: "hxdepots"
perforce_log_volume: "hxlogs"
perforce_online_metadata_volume: "hxmetadata"
perforce_offline_metadata_volume: "hxmetadata"
perforce_domain: "molecule.test"
perforce_mailfrom_email: "perforce-admin@{{ perforce_domain }}"
perforce_mailto_email: "perforce-admin@{{ perforce_domain }}"
perforce_smtp_server: "smtp.{{ perforce_domain }}"
perforce_admin_user: "p4admin"
perforce_admin_user_pass: "F@stSCM!"
perforce_user_password: "$6$PerforceRules$DahgNsXI/V89vqPAXzwflxe7wU09fotIVI5waJACxVd01.EQpQqd5zdnbtgaV.ylstYfQq30xGEBC7yznkE6X1"
admin_users: []
# --- monitoring-role vars ---
p4prometheus_metrics_dir: "/p4/metrics"
p4_network_latency_enabled: true
verifier:
name: ansible
scenario:
# The monitoring role is idempotent (the p4prometheus installer is guarded by
# creates), so the idempotence step re-runs converge and asserts zero changes.
# The p4d bring-up happens in prepare, which is not part of the idempotence run.
test_sequence:
- dependency
- destroy
- syntax
- create
- prepare
- converge
- idempotence
- verify
- destroy
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #2 | 32876 | Russell C. Jackson (Rusty) |
Make both ansible roles idempotent (full converge re-runs cleanly) Existence gate: - main.yml: stat /p4/common/bin/p4_vars -> sdp_installed fact; gate the destructive cleanup (wipe sdp folder + crontab) on 'not sdp_installed' so a re-converge skips wipe/reinstall and only reconciles idempotent config. Run-once installers gated with creates/checks: - run_mkdirs.sh: creates /p4/common/bin/p4_vars (drop changed_when:true). - pyenv: drop changed_when on the creates-guarded bootstrap; add creates for the Python build; gate p4python install on 'pip3 show p4python'. - monitoring prometheus.yml: gate the p4prometheus install script on creates /usr/local/bin/p4prometheus. changed_when:true lies fixed: - login.yml: gate admin/service logins on 'p4 login -s' (only log in when no valid ticket); use command for the no-shell status check. - network_interface.yml: ifup gated on the interface not already being UP. touch/cron idempotence: - authorized_keys touch: modification_time/access_time preserve. - cron/common.yml: remove 'crontab -r' (cron/cronvar modules manage entries idempotently by name; cron.yml is now the authoritative crontab manager). - install/crontab.yml removed + its include dropped: the SDP-generated p4.crontab load was redundant (cron.yml's reset discarded it every run). - packages.yml: apt update_cache cache_valid_time=3600. Molecule: configure_new_server gated behind a marker in the install converge and monitoring prepare; re-added the 'idempotence' step to both scenarios' test_sequence. ansible-lint production-clean; all playbooks syntax-check. |
||
| #1 | 32873 | Russell C. Jackson (Rusty) |
Add full-integration Molecule scenarios for both ansible roles roles/{perforce-sdp-install,perforce-sdp-monitoring}/molecule/default/ each with molecule.yml + prepare.yml + converge.yml + verify.yml. Uses the docker driver with geerlingguy systemd images on Ubuntu 22.04 and Rocky 9 (Debian + RedHat/EL). - install: prepare creates SDP volume dirs; converge runs the role (fresh SDP install -> p4d up) then configure_new_server.sh; verify asserts the service is active, p4 info reports ServerID master, and runs the SDP functional test harness (run_sdp_tests). - monitoring: prepare brings up + configures p4d via the install role; converge applies the monitoring role; verify checks the probe scripts/cron are deployed and runs p4_healthcheck.sh, asserting p4_up=1 against the live server. Idempotence step omitted (a full p4d install is not idempotent). README documents prerequisites and usage. Validated with ansible-playbook --syntax-check and ansible-lint (production profile clean for both the scenarios and the whole project). |