From 294a782a9b4a370975e842891a97b40a05111234 Mon Sep 17 00:00:00 2001 From: tylen Date: Tue, 18 Mar 2025 21:50:06 +0000 Subject: [PATCH] ansible: make docker remotely accessible --- ansible/common_vars.yaml | 2 ++ ansible/hosts.ini | 3 ++- ansible/worker/init.yaml | 17 +++++++++++++++++ ansible/worker/smb.yaml | 17 +++++++++++++++-- ansible/worker/worker_vars.yaml | 3 ++- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ansible/common_vars.yaml b/ansible/common_vars.yaml index 52e51b3..602f339 100644 --- a/ansible/common_vars.yaml +++ b/ansible/common_vars.yaml @@ -23,3 +23,5 @@ common_base_packages: - virtualenv - vim - whois + - jq + - net-tools \ No newline at end of file diff --git a/ansible/hosts.ini b/ansible/hosts.ini index 0a56565..6268ec3 100644 --- a/ansible/hosts.ini +++ b/ansible/hosts.ini @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/ansible/worker/init.yaml b/ansible/worker/init.yaml index 60765c3..9c5ad10 100644 --- a/ansible/worker/init.yaml +++ b/ansible/worker/init.yaml @@ -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 diff --git a/ansible/worker/smb.yaml b/ansible/worker/smb.yaml index d4ed96d..91c3be2 100644 --- a/ansible/worker/smb.yaml +++ b/ansible/worker/smb.yaml @@ -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 diff --git a/ansible/worker/worker_vars.yaml b/ansible/worker/worker_vars.yaml index 2a6267c..69f2f9d 100644 --- a/ansible/worker/worker_vars.yaml +++ b/ansible/worker/worker_vars.yaml @@ -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" \ No newline at end of file