runner

Ansible role that deployes services on my runner machine

1.7 KBYML
docker-network.yml
1.7 KB58 lines • yaml
1---
2# Runner Services - Docker Network Configuration
3
4- name: Create runner docker network
5  community.docker.docker_network:
6    name: "{{ runner_docker_network }}"
7    ipam_config:
8      - subnet: "{{ runner_network_subnet }}"
9    driver: bridge
10    state: present
11    force: true
12  register: runner_network_result
13  check_mode: no
14
15- name: Verify network was created successfully
16  command: docker network inspect {{ runner_docker_network }}
17  register: network_creation_check
18  changed_when: false
19  failed_when: network_creation_check.rc != 0
20
21- name: Display network information
22  debug:
23    msg: |
24      Docker Network Configuration:
25      - Network Name: {{ runner_docker_network }}
26      - Subnet: {{ runner_network_subnet }}
27      - Driver: bridge
28      - State: {{ 'Created' if runner_network_result.changed else 'Already exists' }}
29      - Verification: SUCCESS
30
31- name: Verify network connectivity
32  command: docker network inspect {{ runner_docker_network }}
33  register: network_inspect
34  changed_when: false
35
36- name: Parse network inspection results
37  set_fact:
38    network_info: "{{ (network_inspect.stdout | from_json)[0] }}"
39
40- name: Extract gateway information
41  set_fact:
42    network_gateway: "{{ network_info.IPAM.Config[0].Gateway | default('auto-assigned') if (network_info.IPAM.Config | default([]) | length > 0) else 'auto-assigned' }}"
43
44- name: Display network details
45  debug:
46    msg: |
47      Network Details:
48      - Gateway: {{ network_gateway }}
49      - Subnet: {{ runner_network_subnet }}
50      - Services will communicate through this network
51      
52- name: Create network connectivity test
53  template:
54    src: network-test.sh.j2
55    dest: /usr/local/bin/runner-network-test.sh
56    owner: "{{ runner_user }}"
57    group: "{{ runner_group }}"
58    mode: '0755'