adjust the docker setup

This commit is contained in:
Andreas Zweili 2021-11-12 10:34:43 +01:00
parent e4c185b067
commit 8029666330
3 changed files with 35 additions and 15 deletions

View File

@ -1,12 +1,12 @@
---
- hosts: docker
become: true
roles:
- role: common
vars:
common_deploy_public_key: "/home/andreas/git_repos/projects/tintenwelt/keys/ansible.pub"
- common-server
- restic
# roles:
# - role: common
# vars:
# common_deploy_public_key: "/home/andreas/git_repos/projects/tintenwelt/keys/ansible.pub"
# - common-server
# - restic
tasks:
- import_tasks: tasks/main.yml
vars_files:

View File

@ -5,15 +5,33 @@
when:
- ansible_facts['distribution'] == "Ubuntu"
- name: "Add apt key for Docker"
- name: "Add apt key for Ubuntu Docker"
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
state: present
when:
- ansible_facts['distribution'] == "Ubuntu"
- name: "Add Docker repository"
- name: "Add Docker Ubuntu repository"
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
when:
- ansible_facts['distribution'] == "Ubuntu"
- name: "Add apt key for Debian Docker"
apt_key:
url: "https://download.docker.com/linux/debian/gpg"
state: present
when:
- ansible_facts['distribution'] == "Debian"
- name: "Add Docker Debian repository"
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
when:
- ansible_facts['distribution'] == "Debian"
- name: "Install Docker"
apt:
@ -42,24 +60,26 @@
- name: "Get the Systems repository"
ansible.builtin.git:
repo: "https://git.2li.ch/Nebucatnetzer/docker_systems.git"
dest: "{{ lookup('env', 'HOME') }}/docker_systems"
dest: "/home/{{ ansible_ssh_user }}/docker_systems"
become: no
when: docker_skip_project is undefined
- name: "Get the .env template"
ansible.builtin.fetch:
src: "{{ docker_project_path }}/.env.example"
dest: "/tmp/fetched/{{ inventory_hostname }}.env.example"
src: "{{ docker_project_path }}/.env.j2"
dest: "/tmp/fetched/{{ inventory_hostname }}.env.j2"
flat: yes
fail_on_missing: no
register: env_file
become: no
when: docker_skip_project is undefined
- name: "Copy the .env file"
ansible.builtin.template:
src: "/tmp/fetched/{{ inventory_hostname }}.env.example"
src: "/tmp/fetched/{{ inventory_hostname }}.env.j2"
dest: "{{ docker_project_path }}/.env"
become: no
when: docker_skip_project is undefined
when: docker_skip_project is undefined and env_file.changed
- name: "Open the required UDP ports"
ansible.builtin.ufw:

View File

@ -1,2 +1,2 @@
docker_lazydocker_version: 0.12
docker_project_path: "{{ lookup('env', 'HOME') }}/docker_systems/{{ docker_project_name }}"
docker_project_path: "/home/{{ ansible_ssh_user }}/docker_systems/{{ docker_project_name }}"