From 3601beb92b444a3b5ef95f4e665101e27ea9e744 Mon Sep 17 00:00:00 2001 From: panda Date: Thu, 18 Aug 2022 10:05:24 +0200 Subject: [PATCH] added docker-host --- docker_host.yml | 9 ++++++ repo/disable_iptables.sh | 9 ++++++ repo/docker_daemon.json | 3 ++ roles/docker_host/tasks/debian.yml | 50 ++++++++++++++++++++++++++++++ roles/docker_host/tasks/main.yml | 13 ++++++++ roles/docker_host/tasks/ubuntu.yml | 35 +++++++++++++++++++++ 6 files changed, 119 insertions(+) create mode 100644 docker_host.yml create mode 100755 repo/disable_iptables.sh create mode 100644 repo/docker_daemon.json create mode 100644 roles/docker_host/tasks/debian.yml create mode 100644 roles/docker_host/tasks/main.yml create mode 100644 roles/docker_host/tasks/ubuntu.yml diff --git a/docker_host.yml b/docker_host.yml new file mode 100644 index 0000000..93c673c --- /dev/null +++ b/docker_host.yml @@ -0,0 +1,9 @@ +# playbook.yml: +--- + +- name: "docker_host" + hosts: localhost + connection: local + roles: + - docker_host + diff --git a/repo/disable_iptables.sh b/repo/disable_iptables.sh new file mode 100755 index 0000000..3275b34 --- /dev/null +++ b/repo/disable_iptables.sh @@ -0,0 +1,9 @@ +iptables -F +iptables -X +iptables -t nat -F +iptables -t nat -X +iptables -t mangle -F +iptables -t mangle -X +iptables -P INPUT ACCEPT +iptables -P OUTPUT ACCEPT +iptables -P FORWARD ACCEPT diff --git a/repo/docker_daemon.json b/repo/docker_daemon.json new file mode 100644 index 0000000..5262f79 --- /dev/null +++ b/repo/docker_daemon.json @@ -0,0 +1,3 @@ +{ +"iptables": false +} diff --git a/roles/docker_host/tasks/debian.yml b/roles/docker_host/tasks/debian.yml new file mode 100644 index 0000000..b238378 --- /dev/null +++ b/roles/docker_host/tasks/debian.yml @@ -0,0 +1,50 @@ +- name: Include variables + include_vars: + file: "../../../variables.yml" + +- name: Install docker prerequsistes + apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - software-properties-common + - gnupg-agent + +- name: Add docker repo key + shell: curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - + +- name: add repo for docker + shell: echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list + +- name: Update repositories cache + apt: + update_cache: yes + + +- name: Creates directory + file: + path: /etc/docker + state: directory + +- name: Copy file with owner and permissions + ansible.builtin.copy: + src: ../../../repo/docker_daemon.json + dest: /etc/docker/daemon.json + owner: root + group: root + mode: '0644' + +- name: install docker + apt: + pkg: + - docker-ce + +#install compose: + +- name: download compose +# shell: curl -L https://github.com/docker/compose/releases/download/{{ compose_ver }}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + shell: curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | grep -v sha256 | cut -d '"' -f 4 | wget -O /usr/local/bin/docker-compose -qi - + +- name: make compose executable + shell: chmod +x /usr/local/bin/docker-compose diff --git a/roles/docker_host/tasks/main.yml b/roles/docker_host/tasks/main.yml new file mode 100644 index 0000000..0cbf67a --- /dev/null +++ b/roles/docker_host/tasks/main.yml @@ -0,0 +1,13 @@ +--- + +- include: ubuntu.yml + when: ansible_distribution == 'Ubuntu' +# tags: package + +- include: debian.yml + when: ansible_distribution == 'Debian' +## tags: package + +#- include: redhat.yml +# when: ansible_os_family == 'RedHat' +## tags: package diff --git a/roles/docker_host/tasks/ubuntu.yml b/roles/docker_host/tasks/ubuntu.yml new file mode 100644 index 0000000..103a4f0 --- /dev/null +++ b/roles/docker_host/tasks/ubuntu.yml @@ -0,0 +1,35 @@ +- name: Include variables + include_vars: + file: "../../../variables.yml" + +- name: Install docker prerequsistes + apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - software-properties-common + +- name: Add docker repo key + shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + +- name: add repo for docker + shell: echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" | tee /etc/apt/sources.list.d/docker.list + +- name: Update repositories cache + apt: + update_cache: yes + +- name: telegraf + apt: + pkg: + - docker-ce + +#install compose: + +- name: download compose +# shell: curl -L https://github.com/docker/compose/releases/download/{{ compose_ver }}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + shell: curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | grep -v sha256 | cut -d '"' -f 4 | wget -O /usr/local/bin/docker-compose -qi - + +- name: make compose executable + shell: chmod +x /usr/local/bin/docker-compose