Skip to content

Commit

Permalink
Initial Commit for dockerservice
Browse files Browse the repository at this point in the history
  • Loading branch information
cradle8810 committed Oct 28, 2024
1 parent ae7ef56 commit 58fb295
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/develop_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
matrix:
vm:
- console
- dockerservice
- jenkins
- rui
- runner03
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
matrix:
vm:
- console
- dockerservice
- jenkins
- rui
- runner03
Expand Down Expand Up @@ -128,6 +129,7 @@ jobs:
matrix:
vm:
- console
- dockerservice
- jenkins
- rui
- skylark
Expand Down
43 changes: 43 additions & 0 deletions dockerservice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: Play for docker_service.hayaworld.home
hosts: dockerservice
remote_user: hayato
gather_facts: true
become: true

vars_files:
- inventories/host_vars/docker_service.yml
- inventories/host_vars/networks.yml

handlers:
- name: Restart handler tasks
ansible.builtin.import_tasks:
file: handlers/main.yml
tags:
- network

tasks:
- name: Common Settings
ansible.builtin.import_tasks:
file: tasks/all/main.yml

- name: Install Docker(ce)
ansible.builtin.import_role:
name: geerlingguy.docker
vars:
docker_edition: 'ce'
docker_packages_state: present
docker_service_manage: true
docker_service_state: started
docker_service_enabled: true
docker_restart_handler_state: restarted
docker_users:
- hayato

- name: Mount skylark
ansible.builtin.import_tasks:
file: tasks/dockerservice/mount_docker.yml

- name: Install/Config Zramswap
ansible.builtin.import_tasks:
file: tasks/zram.yml
47 changes: 47 additions & 0 deletions inventories/host_vars/docker_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apt:
- curl
- dstat
- git
- htop
- jq
- open-vm-tools
- openssh-server
- openssl
- p7zip-full
- python3-pip
- sshpass
- vim
- zsh

services_start:
- docker
- open-vm-tools
- ssh

dockerdir:
UUID: "6db90b73-6dbd-4c00-9b13-724f0cb4e636"

firewall:
policy: deny
allow_rules:
- name: "SSH from service line"
proto: "tcp"
src: "192.168.1.0/24"
port: '22'
- name: "Zabbix from Zabbix-server"
proto: "tcp"
src: "192.168.1.106/24"
port: "10050"
- name: "HTTP Allow"
proto: "tcp"
src: "192.168.1.0/24"
port: "80"
- name: "HTTPS Allow"
proto: "tcp"
src: "192.168.1.0/24"
port: "443"

zramswap:
algo: lz4
percent: 50
5 changes: 5 additions & 0 deletions inventories/host_vars/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ network:
ipv4: 192.168.1.100
shortname: rui
sshuser: hayato
- hostname: dockerservice.hayaworld.home
interface: ens160
ipv4: 192.168.1.101
shortname: dockerservice
sshuser: hayato
- hostname: origin.hayaworld.home
interface: ens160
ipv4: 192.168.1.102
Expand Down
3 changes: 3 additions & 0 deletions inventories/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

[macbook]
HayabookAir2023.hayaworld.home ansible_user=hayato

[dockerservice]
192.168.1.101 ansible_user=hayato
2 changes: 1 addition & 1 deletion tasks/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
tags:
- network

- name: "Common / Stop Apt-daily"
- name: "Common / Stop Systemd-resolved"
ansible.builtin.import_tasks:
file: tasks/all/stop-systemd-resolved.yml
tags:
Expand Down
2 changes: 1 addition & 1 deletion tasks/all/stop-systemd-resolved.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
state: present
no_extra_spaces: true
mode: "644"
notify: "systemd-resolved"
notify: "Restart systemd-resolved"
23 changes: 23 additions & 0 deletions tasks/dockerservice/mount_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: "Check if exists /var/lib/docker"
ansible.builtin.stat:
path: "/var/lib/docker"
follow: true
register: dockerdir_stat
failed_when: dockerdir_stat.stat.isdir == false

- name: "Check if exists dockerdir drive"
ansible.builtin.stat:
path: "/dev/disk/by-uuid/{{ dockerdir.UUID }}"
follow: true
register: home_drive
failed_when: home_drive.stat.isblk == false

- name: "Mount dockerdir Drive"
ansible.posix.mount:
src: "UUID={{ dockerdir.UUID }}"
path: "/var/lib/docker"
opts: "defaults"
fstype: ext4
state: mounted
notify: "Restart docker"
6 changes: 6 additions & 0 deletions templates/dockerservice/etc/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_ _ _
__| | ___ ___| | _____ _ __ ___ ___ _ ____ _(_) ___ ___
/ _` |/ _ \ / __| |/ / _ \ '__| / __|/ _ \ '__\ \ / / |/ __/ _ \
| (_| | (_) | (__| < __/ | \__ \ __/ | \ V /| | (_| __/
\__,_|\___/ \___|_|\_\___|_| |___/\___|_| \_/ |_|\___\___|

0 comments on commit 58fb295

Please sign in to comment.