-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IPTables Removed & Some Refactors Applied
- Loading branch information
1 parent
c967a59
commit fbfb59d
Showing
11 changed files
with
153 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
--- | ||
extensions: | ||
- compose: | ||
compose: | ||
version: 1.27.4 | ||
|
||
configure: | ||
compose: no | ||
iptables: no | ||
proxy: no | ||
|
||
docker_proxy: | ||
http: '' | ||
https: '' | ||
|
||
docker_compose: [] | ||
docker_registries: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
--- | ||
- name: installing compose extension | ||
get_url: | ||
url: "https://github.com/docker/compose/releases/download/{{ compose.version | default ('1.27.4') }}/docker-compose-Linux-x86_64" | ||
url: "https://github.com/docker/compose/releases/download/{{ extensions.compose.version | default ('1.27.4') }}/docker-compose-Linux-x86_64" | ||
dest: /usr/local/bin/docker-compose | ||
owner: root | ||
group: root | ||
mode: '0655' | ||
|
||
- name: create necessary directories for placing docker compose manifests | ||
file: | ||
path: "{{ item.destination_path | dirname }}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
with_items: "{{ docker_compose }}" | ||
when: docker_compose is defined | ||
- name: upload defined compose files | ||
block: | ||
- name: create necessary directories for placing docker compose manifests | ||
file: | ||
path: "{{ item.destination_path | dirname }}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
with_items: "{{ docker_compose }}" | ||
|
||
- name: transfer defined compose files based on the domain in srv directory | ||
template: | ||
src: "{{ item.template_path }}" | ||
dest: "{{ item.destination_path }}" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
with_items: "{{ docker_compose }}" | ||
when: docker_compose is defined | ||
- name: transfer defined compose files based on the domain in srv directory | ||
template: | ||
src: "{{ item.template_path }}" | ||
dest: "{{ item.destination_path }}" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
with_items: "{{ docker_compose }}" | ||
|
||
- name: bring up the containers based on docker composes | ||
command: docker-compose up -d | ||
args: | ||
chdir: "{{ item.destination_path | dirname }}" | ||
with_items: "{{ docker_compose }}" | ||
- name: bring up the containers based on docker composes | ||
command: docker-compose up -d | ||
args: | ||
chdir: "{{ item.destination_path | dirname }}" | ||
with_items: "{{ docker_compose }}" | ||
when: | ||
- docker_compose | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
--- | ||
- name: installing necessary packages | ||
apt: | ||
name: "{{ docker_dependencies }}" | ||
update_cache: yes | ||
state: present | ||
force_apt_get: yes | ||
|
||
- name: adding docker gpg key | ||
apt_key: | ||
url: https://download.docker.com/linux/ubuntu/gpg | ||
state: present | ||
environment: | ||
http_proxy: "{{ docker_proxy.http }}" | ||
https_proxy: "{{ docker_proxy.https | default(docker_proxy.http) }}" | ||
|
||
- name: adding docker repository | ||
apt_repository: | ||
repo: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable' | ||
update_cache: yes | ||
state: present | ||
filename: docker | ||
environment: | ||
http_proxy: "{{ docker_proxy.http }}" | ||
https_proxy: "{{ docker_proxy.https | default(docker_proxy.http) }}" | ||
|
||
- name: installing main packages | ||
apt: | ||
name: "{{ docker_packages }}" | ||
update_cache: yes | ||
force_apt_get: yes | ||
name: | ||
- docker-ce | ||
- docker-ce-cli | ||
- containerd.io | ||
environment: | ||
http_proxy: "{{ docker_proxy.http }}" | ||
https_proxy: "{{ docker_proxy.https | default(docker_proxy.http) }}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,18 @@ | ||
--- | ||
- name: installing necessary packages | ||
apt: | ||
name: | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- gnupg-agent | ||
- software-properties-common | ||
- python3-docker | ||
- gnupg2 | ||
- pass | ||
update_cache: yes | ||
state: present | ||
force_apt_get: yes | ||
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' | ||
|
||
- include: distributions/debian.yml | ||
when: ansible_distribution == 'Debian' | ||
|
||
- include: distributions/ubuntu.yml | ||
when: ansible_distribution == 'Ubuntu' | ||
- include_tasks: 'distributions/{{ ansible_distribution | lower }}.yml' | ||
|
||
- name: configure proxy if defined | ||
block: | ||
- name: create systemd necessary directory | ||
file: | ||
path: /etc/systemd/system/docker.service.d | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: '0755' | ||
|
||
- name: create systemd service config file | ||
template: | ||
src: proxy.conf.j2 | ||
dest: /etc/systemd/system/docker.service.d/proxy.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: reload systemd daemon | ||
systemd: | ||
name: docker | ||
daemon_reload: yes | ||
state: restarted | ||
when: configure.proxy | ||
|
||
- name: login to specified registries | ||
shell: "set -o pipefail && echo '{{ item.password }}' | docker login {{ item.url }} --username={{ item.username}} --password-stdin" | ||
with_items: "{{ docker_registries }}" | ||
when: docker_registries is defined | ||
|
||
- include: compose.yml | ||
when: configure.compose | ||
|
||
- include: iptables.yml | ||
when: configure.iptables | ||
include_tasks: proxy.yml | ||
when: | ||
- docker_proxy.http is defined | ||
- docker_proxy.http != '' | ||
|
||
- name: login to defined registries | ||
include_tasks: registries.yml | ||
when: | ||
- docker_registries | length > 0 | ||
|
||
- name: install and configure compose extension | ||
include_tasks: compose.yml | ||
when: | ||
- extensions.compose is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: create systemd necessary directory | ||
file: | ||
path: /etc/systemd/system/docker.service.d | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: '0755' | ||
|
||
- name: create systemd service config file | ||
template: | ||
src: proxy.conf.j2 | ||
dest: /etc/systemd/system/docker.service.d/proxy.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: reload systemd daemon | ||
systemd: | ||
name: docker | ||
daemon_reload: yes | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: add necessary users to docker group | ||
user: | ||
name: "{{ item.user }}" | ||
groups: | ||
- docker | ||
with_items: "{{ docker_registries }}" | ||
|
||
- name: login to specified registries | ||
shell: "echo '{{ item.password }}' | docker login {{ item.url }} --username={{ item.username }} --password-stdin" | ||
become: yes | ||
become_method: sudo | ||
become_user: '{{ item.user }}' | ||
with_items: "{{ docker_registries }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[Service] | ||
Environment="HTTP_PROXY={{ docker_proxy.http }}" | ||
Environment="HTTPS_PROXY={{ docker_proxy.https }}" | ||
Environment="HTTPS_PROXY={{ docker_proxy.https | default(docker_proxy.http) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
docker_dependencies: | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- gnupg-agent | ||
- software-properties-common | ||
- python3-docker | ||
- gnupg2 | ||
|
||
docker_packages: | ||
- docker-ce | ||
- docker-ce-cli | ||
- containerd.io |