feat(test): some test refactoring

This commit is contained in:
Bertrand Lanson 2023-12-11 19:01:57 +01:00
parent 248c9726a3
commit bf3da5e806
14 changed files with 39 additions and 55 deletions

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.deploy_gitea_runner" - name: "Include ednxzu.deploy_gitea_runner"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -1,17 +1,10 @@
--- ---
- name: Prepare - name: Prepare
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.install_docker" - name: "Include ednxzu.install_docker"
ansible.builtin.include_role: ansible.builtin.include_role:
name: ednxzu.install_docker name: ednxzu.install_docker
vars: vars:
install_docker_edition: ce
install_docker_start_service: true
install_docker_compose: false
install_docker_compose_version: latest
install_docker_python_packages: true install_docker_python_packages: true
install_docker_python_packages_version: latest
install_docker_users: []
install_docker_daemon_options:
live-restore: true

View File

@ -3,4 +3,5 @@
roles: roles:
- name: ednxzu.manage_repositories - name: ednxzu.manage_repositories
- name: ednxzu.manage_apt_packages - name: ednxzu.manage_apt_packages
- name: mhutter.docker-systemd-service - name: ednxzu.install_docker
- name: ednxzu.docker_systemd_service

View File

@ -1,7 +1,8 @@
--- ---
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: false gather_facts: true
become: true
tasks: tasks:
- name: "Test: file /etc/hosts" - name: "Test: file /etc/hosts"
block: block:

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.deploy_gitea_runner" - name: "Include ednxzu.deploy_gitea_runner"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -4,16 +4,16 @@ deploy_gitea_runner_version: latest
deploy_gitea_runner_deploy_method: docker # deployment method, either host or docker. deploy_gitea_runner_deploy_method: docker # deployment method, either host or docker.
deploy_gitea_runner_directory: /opt/gitea-actions deploy_gitea_runner_directory: /opt/gitea-actions
deploy_gitea_runner_timezone: "Europe/Paris" deploy_gitea_runner_timezone: "Europe/Paris"
deploy_gitea_runner_register: true deploy_gitea_runner_register: false
deploy_gitea_runner_start_service: true deploy_gitea_runner_start_service: false
deploy_gitea_runner_server_url: https://git.example.com deploy_gitea_runner_server_url: https://git.ednz.fr
deploy_gitea_runner_server_token: "" deploy_gitea_runner_server_token: ""
deploy_gitea_runner_name: gitea-runner deploy_gitea_runner_name: vagrant-gitea-runner
deploy_gitea_runner_config: deploy_gitea_runner_config:
log: log:
level: info level: info
runner: runner:
file: ".runner" # this HAS TO BE .runner if deploy_gitea_runner_deploy_method is docker file: "{{ deploy_gitea_runner_directory }}/.runner" # this HAS TO BE .runner if deploy_gitea_runner_deploy_method is docker
capacity: 1 capacity: 1
timeout: 3h timeout: 3h
insecure: false insecure: false
@ -22,7 +22,7 @@ deploy_gitea_runner_config:
labels: [] labels: []
cache: cache:
enabled: true enabled: true
dir: "/cache" # this HAS TO BE /cache if deploy_gitea_runner_deploy_method is docker dir: "{{ deploy_gitea_runner_directory }}/cache" # this HAS TO BE /cache if deploy_gitea_runner_deploy_method is docker
host: 127.0.0.1 host: 127.0.0.1
port: 4974 port: 4974
container: container:

View File

@ -1,17 +1,10 @@
--- ---
- name: Prepare - name: Prepare
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.install_docker" - name: "Include ednxzu.install_docker"
ansible.builtin.include_role: ansible.builtin.include_role:
name: ednxzu.install_docker name: ednxzu.install_docker
vars: vars:
install_docker_edition: ce
install_docker_start_service: true
install_docker_compose: false
install_docker_compose_version: latest
install_docker_python_packages: true install_docker_python_packages: true
install_docker_python_packages_version: latest
install_docker_users: []
install_docker_daemon_options:
live-restore: true

View File

@ -3,4 +3,5 @@
roles: roles:
- name: ednxzu.manage_repositories - name: ednxzu.manage_repositories
- name: ednxzu.manage_apt_packages - name: ednxzu.manage_apt_packages
- name: mhutter.docker-systemd-service - name: ednxzu.install_docker
- name: ednxzu.docker_systemd_service

View File

@ -2,4 +2,5 @@
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: true gather_facts: true
become: true
tasks: tasks:

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.deploy_gitea_runner" - name: "Include ednxzu.deploy_gitea_runner"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -3,4 +3,4 @@
roles: roles:
- name: ednxzu.manage_repositories - name: ednxzu.manage_repositories
- name: ednxzu.manage_apt_packages - name: ednxzu.manage_apt_packages
- name: mhutter.docker-systemd-service - name: ednxzu.docker_systemd_service

View File

@ -1,7 +1,8 @@
--- ---
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: false gather_facts: true
become: true
tasks: tasks:
- name: "Test: file /etc/hosts" - name: "Test: file /etc/hosts"
block: block:

View File

@ -1,6 +1,6 @@
--- ---
# task/configure file for deploy_adguard # task/configure file for deploy_adguard
- name: "configure host installation" - name: "Configure host installation"
when: deploy_gitea_runner_deploy_method == 'host' when: deploy_gitea_runner_deploy_method == 'host'
block: block:
- name: "Copy gitea-runnner.service file" - name: "Copy gitea-runnner.service file"
@ -27,7 +27,7 @@
- systemctl-enable-gitea-runner - systemctl-enable-gitea-runner
- systemctl-restart-gitea-runner - systemctl-restart-gitea-runner
- name: "configure docker installation" - name: "Configure docker installation"
when: deploy_gitea_runner_deploy_method == 'docker' when: deploy_gitea_runner_deploy_method == 'docker'
block: block:
- name: "Copy config.yaml" - name: "Copy config.yaml"
@ -39,4 +39,3 @@
mode: '0600' mode: '0600'
when: deploy_gitea_runner_config != {} when: deploy_gitea_runner_config != {}
become: true become: true

View File

@ -1,36 +1,27 @@
--- ---
# task/install_docker file for deploy_gitea_runner # task/install_docker file for deploy_gitea_runner
- name: "Include mhutter.docker-systemd-service" - name: "Include ednxzu.docker_systemd_service"
ansible.builtin.include_role: ansible.builtin.include_role:
name: mhutter.docker-systemd-service name: ednxzu.docker_systemd_service
apply: apply:
become: true become: true
vars: vars:
container_image: "gitea/act_runner:{{ deploy_gitea_runner_version }}" docker_systemd_service_container_name: "{{ deploy_gitea_runner_name }}"
container_name: "{{ deploy_gitea_runner_name }}" docker_systemd_service_image: "gitea/act_runner:{{ deploy_gitea_runner_version }}"
container_docker_pull: true docker_systemd_service_container_env:
container_docker_pull_force_source: true
container_host_network: false
container_network: "bridge"
container_ports: "{{ [deploy_gitea_runner_config.cache.port ~ ':' ~ deploy_gitea_runner_config.cache.port] if deploy_gitea_runner_config.cache.enabled else [] }}"
container_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "{{ deploy_gitea_runner_directory }}/config.yaml:/config.yaml"
- "{{ deploy_gitea_runner_directory }}/data:/data"
- "{{ deploy_gitea_runner_directory }}/cache:/cache"
container_env:
TZ: "{{ deploy_gitea_runner_timezone }}" TZ: "{{ deploy_gitea_runner_timezone }}"
CONFIG_FILE: /config.yaml CONFIG_FILE: /config.yaml
GITEA_INSTANCE_URL: "{{ deploy_gitea_runner_server_url }}" GITEA_INSTANCE_URL: "{{ deploy_gitea_runner_server_url }}"
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ deploy_gitea_runner_server_token }}" GITEA_RUNNER_REGISTRATION_TOKEN: "{{ deploy_gitea_runner_server_token }}"
GITEA_RUNNER_NAME: "{{ deploy_gitea_runner_name }}" GITEA_RUNNER_NAME: "{{ deploy_gitea_runner_name }}"
service_name: "{{ deploy_gitea_runner_name }}_container" docker_systemd_service_flags:
service_systemd_options: [] - network: bridge
service_systemd_unit_options: - volume:
After: docker.service - "/var/run/docker.sock:/var/run/docker.sock"
PartOf: docker.service - "{{ deploy_gitea_runner_directory }}/config.yaml:/config.yaml"
Requires: docker.service - "{{ deploy_gitea_runner_directory }}/data:/data"
service_enabled: true - "{{ deploy_gitea_runner_directory }}/cache:/cache"
service_masked: false - publish: "{{ [deploy_gitea_runner_config.cache.port ~ ':' ~ deploy_gitea_runner_config.cache.port] if deploy_gitea_runner_config.cache.enabled else [] }}"
service_state: "{{ 'started' if deploy_gitea_runner_start_service else 'stopped'}}" docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
service_restart: false docker_systemd_service_state: "{{ 'started' if deploy_gitea_runner_start_service else 'stopped'}}"
docker_systemd_service_restart: "{{ true if deploy_gitea_runner_start_service else false}}"