From 9d36cfabe1253f8b8916a200061e89aa59cb26c8 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 20 Aug 2021 14:57:22 +0300 Subject: roles/server -> roles/my-server --- maintenance.yml | 2 +- roles/my-server/defaults/main.yml | 1 + roles/my-server/tasks/main.yml | 23 +++++++++++++++++++++++ roles/server/defaults/main.yml | 1 - roles/server/tasks/main.yml | 23 ----------------------- 5 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 roles/my-server/defaults/main.yml create mode 100644 roles/my-server/tasks/main.yml delete mode 100644 roles/server/defaults/main.yml delete mode 100644 roles/server/tasks/main.yml diff --git a/maintenance.yml b/maintenance.yml index cb2c80b..d9e391d 100644 --- a/maintenance.yml +++ b/maintenance.yml @@ -4,7 +4,7 @@ - snap - apt - pacman - - server + - my-server - docker - flatpak - vagrant diff --git a/roles/my-server/defaults/main.yml b/roles/my-server/defaults/main.yml new file mode 100644 index 0000000..eda8336 --- /dev/null +++ b/roles/my-server/defaults/main.yml @@ -0,0 +1 @@ +server_dir: '{{ ansible_env.HOME }}/server' diff --git a/roles/my-server/tasks/main.yml b/roles/my-server/tasks/main.yml new file mode 100644 index 0000000..05ef180 --- /dev/null +++ b/roles/my-server/tasks/main.yml @@ -0,0 +1,23 @@ +- name: 'Check if {{ server_dir }}/docker-compose.yml exists' + stat: + path: '{{ server_dir }}/docker-compose.yml' + register: server_exists + +- when: server_exists.stat.exists + become: true + block: + # community.docker.docker_compose is too confusing for me to use, sorry. + - name: docker-compose pull + command: docker-compose pull --quiet + args: + chdir: '{{ server_dir }}' + + - name: docker-compose build + command: docker-compose build --pull + args: + chdir: '{{ server_dir }}' + + - name: docker-compose up + command: docker-compose up -d + args: + chdir: '{{ server_dir }}' diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml deleted file mode 100644 index eda8336..0000000 --- a/roles/server/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -server_dir: '{{ ansible_env.HOME }}/server' diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml deleted file mode 100644 index 05ef180..0000000 --- a/roles/server/tasks/main.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: 'Check if {{ server_dir }}/docker-compose.yml exists' - stat: - path: '{{ server_dir }}/docker-compose.yml' - register: server_exists - -- when: server_exists.stat.exists - become: true - block: - # community.docker.docker_compose is too confusing for me to use, sorry. - - name: docker-compose pull - command: docker-compose pull --quiet - args: - chdir: '{{ server_dir }}' - - - name: docker-compose build - command: docker-compose build --pull - args: - chdir: '{{ server_dir }}' - - - name: docker-compose up - command: docker-compose up -d - args: - chdir: '{{ server_dir }}' -- cgit v1.2.3