From a8345d0d45efe4aaf416aa189e5546f2f08a0ac2 Mon Sep 17 00:00:00 2001 From: David Petric Date: Mon, 27 Mar 2023 20:54:28 +0200 Subject: [PATCH] Add containers --- roles/.DS_Store | Bin 0 -> 6148 bytes roles/configure-php/tasks/main.yml | 1 - roles/setup-containers/files/mysql.j2 | 19 ++++++++++++ roles/setup-containers/files/redis.j2 | 12 ++++++++ roles/setup-containers/tasks/main.yml | 40 ++++++++++++++++++++++++++ setup_server.yml | 3 +- vars/external.yml | 9 +++++- 7 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 roles/.DS_Store create mode 100644 roles/setup-containers/files/mysql.j2 create mode 100644 roles/setup-containers/files/redis.j2 create mode 100644 roles/setup-containers/tasks/main.yml diff --git a/roles/.DS_Store b/roles/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d230230106e189aea336232f217a0a9cd7ad4e01 GIT binary patch literal 6148 zcmeHKL2uJA6n^dsOR2_!0BIMbNL*Lw*i;E|DP)CL%GKM0-Ro5jjYV?Q6)^7`Jn3Sj*IO zfkKUu&@oM@pqP4%-nPOjU={e=6yUYHO-CdtqxV!_zZuqYg4&PIQh5}nGDJ__CLSZ* z`>6~iqOG;;oK7fTVSZg<-dxL^;#~@gC|CPPN#*h=;todnQk(yhqlD8kH(q=T^E4@| ze*e2@ZM3gk-E=mcuJhJEkyF14s!2Htir4(~LdrBeF9+evB%Y4lTTf(G1xXecijYJx zy1aRnWRaYX<$?9{~?eV4y4 zM?sx?L1YMizdEzqm~~B5h#xDg8x7WPBBI4!*5`HcwlRF2AclG-#@KWA1OBc?6meYE zBWhbQBQPp;lI19|RsmK-++g#1sI&3-kC=%whxY($RspMkRiLf_?++dlJG1O>ttAJHtS%D4x=<@mh^y2&fGRZz!1*`)9l>(xD=pT;Yk~v!&&hc66A-zLl q<9-W`ih|4>$Ev_b@eYzQw0T?r4h=3eq6TLF2q+nBW)=9O3j6}_WaUQy literal 0 HcmV?d00001 diff --git a/roles/configure-php/tasks/main.yml b/roles/configure-php/tasks/main.yml index 57e35e6..53c9f9d 100644 --- a/roles/configure-php/tasks/main.yml +++ b/roles/configure-php/tasks/main.yml @@ -1,5 +1,4 @@ --- - - name: PHP ini setup copy: src: files/php{{ php_version }}.ini diff --git a/roles/setup-containers/files/mysql.j2 b/roles/setup-containers/files/mysql.j2 new file mode 100644 index 0000000..c827fa2 --- /dev/null +++ b/roles/setup-containers/files/mysql.j2 @@ -0,0 +1,19 @@ +version: '3' + +services: + db: + container_name: mysql8 + image: mysql:8.0 + command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + ports: + - '127.0.0.1:3306:3306' + environment: + MYSQL_ROOT_PASSWORD: {{ mysql_root_pass }} + MYSQL_DATABASE: {{ mysql_db }} + MYSQL_USER: {{ mysql_user }} + MYSQL_PASSWORD: {{ mysql_user_pass }} + volumes: + - '/opt/docker/mysql:/var/lib/mysql' + mem_limit: {{ mysql_mem_limit }}M + mem_reservation: {{ mysql_mem_reserve }}M + restart: always \ No newline at end of file diff --git a/roles/setup-containers/files/redis.j2 b/roles/setup-containers/files/redis.j2 new file mode 100644 index 0000000..719f262 --- /dev/null +++ b/roles/setup-containers/files/redis.j2 @@ -0,0 +1,12 @@ +version: '3' + +services: + cache: + container_name: redis + image: redis:6.2-alpine + restart: always + ports: + - '127.0.0.1:6379:6379' + command: redis-server --loglevel warning --requirepass {{ redis_pass }} + volumes: + - /opt/docker/redis:/data \ No newline at end of file diff --git a/roles/setup-containers/tasks/main.yml b/roles/setup-containers/tasks/main.yml new file mode 100644 index 0000000..9991602 --- /dev/null +++ b/roles/setup-containers/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: Create compose dir + file: + path: /opt/docker/compose-files + state: directory + mode: '0755' + +- name: Create MySQL dirs + file: + path: /opt/docker/compose-files/mysql + state: directory + mode: '0755' + +- name: Create MySQL dirs + file: + path: /opt/docker/mysql + state: directory + mode: '0755' + +- name: Copy MySQL compose file + template: + src: files/mysql.j2 + dest: /opt/docker/compose-files/mysql/docker-compose.yaml + +- name: Create Redis dirs + file: + path: /opt/docker/compose-files/redis + state: directory + mode: '0755' + +- name: Create Redisdirs + file: + path: /opt/docker/redis + state: directory + mode: '0755' + +- name: Copy Redis compose file + template: + src: files/redis.j2 + dest: /opt/docker/compose-files/redis/docker-compose.yml \ No newline at end of file diff --git a/setup_server.yml b/setup_server.yml index 3119c5c..77f5d6b 100644 --- a/setup_server.yml +++ b/setup_server.yml @@ -12,4 +12,5 @@ - role: install-php - role: configure-php - role: install-wordpress - - role: install-docker \ No newline at end of file + - role: install-docker + - role: setup-containers \ No newline at end of file diff --git a/vars/external.yml b/vars/external.yml index b31ecb6..814bb05 100644 --- a/vars/external.yml +++ b/vars/external.yml @@ -2,4 +2,11 @@ php_version: 8.1 vhost_name: projectwp domain: projectwp.com -db_pwd: 123456 \ No newline at end of file +db_pwd: 123456 +mysql_mem_limit: 1024 +mysql_mem_reserve: 512 +mysql_root_pass: xyz +mysql_db: projectwp +mysql_user: projectwp +mysql_user_pass: xyz +redis_pass: xyz \ No newline at end of file