Skip to content

Commit

Permalink
Adding proxy for docker service only for Fedora (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-zak authored Apr 19, 2022
1 parent f1118f6 commit baa376f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ N/A
* `docker_users`: A list of users to add to the docker group. They will not be evaluated until a session is created.
* `docker_service_state`: Docker service state
* `docker_service_enabled`: Docker service enable status
* `docker_service_proxy`: Docker service proxy (using only for Fedora). Default value `1.1.1.1`

## Dependencies

Expand Down
5 changes: 3 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
docker_ubuntu_release:
docker_debian_release:
docker_ubuntu_release:
docker_debian_release:
docker_service_state: started
docker_service_enabled: true
docker_service_proxy: 1.1.1.1

docker_users:
- root
9 changes: 5 additions & 4 deletions tasks/install/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

- name: Install Docker dependencies
ansible.builtin.yum:
name:
name:
- yum-utils
state: present
register: result
Expand All @@ -30,11 +30,12 @@
- name: Install Docker
ansible.builtin.yum:
name:
- docker-ce
- docker-ce-cli
- docker-ce
- docker-ce-cli
- containerd.io
state: present
register: result
until: result is success
retries: 5
delay: 5
delay: 5

6 changes: 3 additions & 3 deletions tasks/install/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
- name: Install Docker
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- docker-ce
- docker-ce-cli
- containerd.io
state: present
state: present
26 changes: 25 additions & 1 deletion tasks/install/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,28 @@
until: result is success
retries: 5
delay: 5
changed_when: false
changed_when: false

- name: Create directory for Docker proxy configuration
ansible.builtin.file:
path: /etc/systemd/system/docker.service.d/
state: directory
owner: root
group: root
mode: '0755'
changed_when: false

- name: Create Docker service proxy configuration
ansible.builtin.template:
src: 10_docker_proxy.conf.j2
dest: /etc/systemd/system/docker.service.d/10_docker_proxy.conf
owner: root
group: root
mode: '0644'
changed_when: false

- name: Reload Docker service configuration
ansible.builtin.systemd:
name: docker.service
daemon_reload: yes
changed_when: false
2 changes: 1 addition & 1 deletion tasks/install/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
- docker-ce
- docker-ce-cli
- containerd.io
state: present
state: present
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
include_tasks: install/ubuntu.yml
when: ansible_distribution == 'Ubuntu'

- include_tasks: post_process.yml
- include_tasks: post_process.yml
2 changes: 1 addition & 1 deletion tasks/post_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
groups: docker
append: true
with_items: "{{ docker_users }}"
when: docker_users | length > 0
when: docker_users | length > 0
3 changes: 3 additions & 0 deletions templates/10_docker_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Service]
Environment=HTTP_PROXY=http://{{ docker_service_proxy }}:111
Environment=HTTPS_PROXY=http://{{ docker_service_proxy }}:111

0 comments on commit baa376f

Please sign in to comment.