Browse Source

added docker-host

panda 1 year ago
parent
commit
3601beb92b

+ 9 - 0
docker_host.yml

@@ -0,0 +1,9 @@
+# playbook.yml:
+--- 
+
+- name: "docker_host"
+  hosts: localhost
+  connection: local
+  roles:
+    - docker_host
+    

+ 9 - 0
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

+ 3 - 0
repo/docker_daemon.json

@@ -0,0 +1,3 @@
+{
+"iptables": false
+}

+ 50 - 0
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

+ 13 - 0
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

+ 35 - 0
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