144 lines
6.2 KiB
YAML
144 lines
6.2 KiB
YAML
---
|
|
- name: Verify
|
|
hosts: all
|
|
gather_facts: true
|
|
become: true
|
|
tasks:
|
|
- name: "Test: directory /opt/gitea-actions"
|
|
block:
|
|
- name: "Stat directory /opt/gitea-actions"
|
|
ansible.builtin.stat:
|
|
path: "/opt/gitea-actions"
|
|
register: stat_opt_gitea_actions
|
|
|
|
- name: "Stat directory /opt/gitea-actions/cache"
|
|
ansible.builtin.stat:
|
|
path: "/opt/gitea-actions"
|
|
register: stat_opt_gitea_actions_cache
|
|
|
|
- name: "Stat directory /opt/gitea-actions/data"
|
|
ansible.builtin.stat:
|
|
path: "/opt/gitea-actions"
|
|
register: stat_opt_gitea_actions_data
|
|
|
|
- name: "Stat file /opt/gitea-actions/config.yaml"
|
|
ansible.builtin.stat:
|
|
path: "/opt/gitea-actions/config.yaml"
|
|
register: stat_opt_gitea_actions_config_yaml
|
|
|
|
- name: "Slurp file /opt/gitea-actions/config.yaml"
|
|
ansible.builtin.slurp:
|
|
src: "/opt/gitea-actions/config.yaml"
|
|
register: slurp_opt_gitea_actions_config_yaml
|
|
|
|
- name: "Verify directory /opt/gitea-actions"
|
|
vars:
|
|
expected_act_config_file: |
|
|
# Ansible managed: Do NOT edit this file manually!
|
|
cache:
|
|
dir: /cache
|
|
enabled: true
|
|
external_server: null
|
|
host: 127.0.0.1
|
|
port: 9898
|
|
container:
|
|
docker_host: ''
|
|
network: ''
|
|
options: ''
|
|
privileged: false
|
|
valid_volumes: []
|
|
workdir_parent: null
|
|
host:
|
|
workdir_parent: null
|
|
log:
|
|
level: info
|
|
runner:
|
|
capacity: 1
|
|
fetch_interval: 2s
|
|
fetch_timeout: 5s
|
|
file: .runner
|
|
insecure: false
|
|
labels:
|
|
- debian-bullseye:docker://node:16-bullseye
|
|
timeout: 3h
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_opt_gitea_actions.stat.exists
|
|
- stat_opt_gitea_actions.stat.isdir
|
|
- stat_opt_gitea_actions.stat.pw_name == 'root'
|
|
- stat_opt_gitea_actions.stat.gr_name == 'root'
|
|
- stat_opt_gitea_actions.stat.mode == '0755'
|
|
- stat_opt_gitea_actions_cache.stat.exists
|
|
- stat_opt_gitea_actions_cache.stat.isdir
|
|
- stat_opt_gitea_actions_cache.stat.pw_name == 'root'
|
|
- stat_opt_gitea_actions_cache.stat.gr_name == 'root'
|
|
- stat_opt_gitea_actions_cache.stat.mode == '0755'
|
|
- stat_opt_gitea_actions_data.stat.exists
|
|
- stat_opt_gitea_actions_data.stat.isdir
|
|
- stat_opt_gitea_actions_data.stat.pw_name == 'root'
|
|
- stat_opt_gitea_actions_data.stat.gr_name == 'root'
|
|
- stat_opt_gitea_actions_data.stat.mode == '0755'
|
|
- stat_opt_gitea_actions_config_yaml.stat.exists
|
|
- stat_opt_gitea_actions_config_yaml.stat.isreg
|
|
- stat_opt_gitea_actions_config_yaml.stat.pw_name == 'root'
|
|
- stat_opt_gitea_actions_config_yaml.stat.gr_name == 'root'
|
|
- stat_opt_gitea_actions_config_yaml.stat.mode == '0600'
|
|
- (slurp_opt_gitea_actions_config_yaml.content|b64decode) == expected_act_config_file
|
|
|
|
- name: "Test: service gitea-runner_container"
|
|
block:
|
|
- name: "Get service gitea-runner_container"
|
|
ansible.builtin.service_facts:
|
|
|
|
- name: "Stat file /etc/systemd/system/gitea-runner_container.service"
|
|
ansible.builtin.stat:
|
|
path: "/etc/systemd/system/gitea-runner_container.service"
|
|
register: stat_etc_systemd_system_gitea_runner_container_service
|
|
|
|
- name: "Slurp file /etc/systemd/system/gitea-runner_container.service"
|
|
ansible.builtin.slurp:
|
|
src: "/etc/systemd/system/gitea-runner_container.service"
|
|
register: slurp_etc_systemd_system_gitea_runner_container_service
|
|
|
|
- name: "Verify service gitea-runner"
|
|
vars:
|
|
gitea_runner_expected_service_file: |
|
|
# Ansible managed: Do NOT edit this file manually!
|
|
[Unit]
|
|
After=docker.service
|
|
PartOf=docker.service
|
|
Requires=docker.service
|
|
|
|
[Service]
|
|
EnvironmentFile=/etc/default/gitea-runner
|
|
ExecStartPre=-/usr/bin/docker rm -f gitea-runner
|
|
ExecStart=/usr/bin/docker run --name gitea-runner \
|
|
--rm \
|
|
--env-file /etc/default/gitea-runner \
|
|
--network "bridge" \
|
|
--volume "/var/run/docker.sock:/var/run/docker.sock" \
|
|
--volume "/opt/gitea-actions/config.yaml:/config.yaml" \
|
|
--volume "/opt/gitea-actions/data:/data" \
|
|
--volume "/opt/gitea-actions/cache:/cache" \
|
|
--publish "9898:9898" \
|
|
gitea/act_runner:latest
|
|
ExecStop=/usr/bin/docker stop gitea-runner
|
|
SyslogIdentifier=gitea-runner
|
|
Restart=always
|
|
RestartSec=10s
|
|
|
|
[Install]
|
|
WantedBy=docker.service
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_etc_systemd_system_gitea_runner_container_service.stat.exists
|
|
- stat_etc_systemd_system_gitea_runner_container_service.stat.isreg
|
|
- stat_etc_systemd_system_gitea_runner_container_service.stat.pw_name == 'root'
|
|
- stat_etc_systemd_system_gitea_runner_container_service.stat.gr_name == 'root'
|
|
- stat_etc_systemd_system_gitea_runner_container_service.stat.mode == '0644'
|
|
- (slurp_etc_systemd_system_gitea_runner_container_service.content|b64decode) == gitea_runner_expected_service_file
|
|
- ansible_facts.services['gitea-runner_container.service'] is defined
|
|
- ansible_facts.services['gitea-runner_container.service']['source'] == 'systemd'
|
|
- ansible_facts.services['gitea-runner_container.service']['state'] == 'stopped'
|
|
- ansible_facts.services['gitea-runner_container.service']['status'] == 'enabled'
|