ansible: make docker remotely accessible

This commit is contained in:
tylen 2025-03-18 21:50:06 +00:00
parent b9dac2daaa
commit 294a782a9b
5 changed files with 38 additions and 4 deletions

View File

@ -23,3 +23,5 @@ common_base_packages:
- virtualenv
- vim
- whois
- jq
- net-tools

View File

@ -1,3 +1,4 @@
[workers]
vm-jenkins-100-30 ansible_host=192.168.100.30 ansible_user=tylen
vm-tools-100-55 ansible_host=192.168.100.55 ansible_user=tylen
vm-tools-100-65 ansible_host=192.168.100.65 ansible_user=tylen

View File

@ -30,6 +30,23 @@
state: latest
update_cache: true
- name: Ensure the Docker service file is backed up
copy:
src: /lib/systemd/system/docker.service
dest: /lib/systemd/system/docker.service.bak
remote_src: yes
when: ansible_distribution == "Ubuntu"
- name: Update ExecStart in Docker service file with exposing the port
lineinfile:
path: /lib/systemd/system/docker.service
regexp: '^ExecStart='
line: 'ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375'
state: present
- name: Reload systemd to apply changes
command: systemctl daemon-reload
- name: Start and enable Docker
service:
name: docker

View File

@ -16,7 +16,14 @@
- name: Create remote-apps directory
file:
path: "{{ mount_path }}"
path: "{{ remote_apps_mount_path }}"
state: directory
owner: "{{ vm_username }}"
group: "{{ vm_username }}"
- name: Create Media directory
file:
path: "{{ media_mount_path }}"
state: directory
owner: "{{ vm_username }}"
group: "{{ vm_username }}"
@ -32,7 +39,13 @@
- name: Add ~/remote-apps entry to fstab
lineinfile:
dest: /etc/fstab
line: '//{{ nas_ip }}/apps {{ mount_path }} cifs credentials={{ cred_path }}/smb,uid=vm-user 0 0'
line: '//{{ nas_ip }}/apps {{ remote_apps_mount_path }} cifs credentials={{ cred_path }}/smb,uid=vm-user 0 0'
state: present
- name: Add ~/Media entry to fstab
lineinfile:
dest: /etc/fstab
line: '//{{ nas_ip }}/Media {{ media_mount_path }} cifs credentials={{ cred_path }}/smb,uid=vm-user 0 0'
state: present
- name: Mount all disks

View File

@ -2,6 +2,7 @@
vm_username: vm-user
vm_home: "/home/{{ vm_username }}"
cred_path: "{{ vm_home }}/.cred"
mount_path: "{{ vm_home }}/remote-apps"
remote_apps_mount_path: "{{ vm_home }}/remote-apps"
media_mount_path: "{{ vm_home }}/Media"
bashrc_mount_path: "{{ vm_home }}/.bashrc"
vimrc_mount_path: "{{ vm_home }}/.vimrc"