-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfunction_github_runner_create.yml
More file actions
86 lines (73 loc) · 2.49 KB
/
Copy pathfunction_github_runner_create.yml
File metadata and controls
86 lines (73 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
- name: Create Github Runner
hosts: "{{ host | default('localhost') }}"
gather_facts: true
roles:
- role: monolithprojects.github_actions_runner
when: create_github_runner | bool()
tags: create_github_runner
become: true
post_tasks:
- name: Install container-tools
become: true
ansible.builtin.dnf:
name: container-tools
state: present
- name: Enable and start podman service
become: true
ansible.builtin.systemd:
name: podman
enabled: true
state: started
- name: Create .bashrc.d directory if it doesn't exist
ansible.builtin.file:
path: "{{ ansible_env.HOME }}/.bashrc.d"
state: directory
mode: "0755"
- name: Set XDG_RUNTIME_DIR in systemd file
ansible.builtin.copy:
dest: "{{ ansible_env.HOME }}/.bashrc.d/systemd"
mode: "0640"
content: |
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export DOCKER_HOST="unix:$XDG_RUNTIME_DIR/podman/podman.sock"
- name: Source the new environment variable file
ansible.builtin.shell: source ~/.bashrc.d/systemd
args:
executable: /bin/bash
changed_when: false
- name: Enable and start podman.socket for user
ansible.builtin.systemd:
name: podman.socket
enabled: true
state: started
scope: user
- name: Remove /var/run/docker.sock if it exists
become: true
ansible.builtin.file:
path: /var/run/docker.sock
state: absent
- name: Create symlink for podman socket
become: true
ansible.builtin.file:
src: "{{ ansible_env.XDG_RUNTIME_DIR }}/podman/podman.sock"
dest: /var/run/docker.sock
state: link
mode: "0640"
- name: Create script to create Docker socket link
ansible.builtin.copy:
dest: "{{ ansible_env.HOME }}/create-docker-sock-link.sh"
content: |
#!/bin/bash
# Remove the existing symbolic link if it exists
if [ -L /var/run/docker.sock ]; then
sudo rm /var/run/docker.sock
fi
# Create a new symbolic link to the correct Podman socket
sudo ln -s $XDG_RUNTIME_DIR/podman/podman.sock /var/run/docker.sock
mode: "0750"
- name: Create cron job to ensure Docker socket link at boot
ansible.builtin.cron:
name: Ensure Docker socket link at boot
special_time: reboot
job: "{{ ansible_env.HOME }}/create-docker-sock-link.sh"