Skip to content

Commit 435b736

Browse files
committed
feat: support optional copying of custom SSL certificates
1 parent 3d6c637 commit 435b736

5 files changed

Lines changed: 81 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ git submodule add https://github.com/6C656C65/pyproxy_ansible roles/pyproxy
2525
By default, the installation method uses Docker Compose.
2626
You can change the installation method and adjust other settings in the `./defaults/main.yml` file, either directly or by overriding variables in your playbook.
2727

28+
### 🔐 **SSL Certificate Handling**
29+
30+
If you want to provide your own SSL inspection certificates, you can configure the role to copy them to the target machine.
31+
32+
* Set the variable `pyproxy."method".ssl_inspect_ca_folder` to the **path of the folder** containing your certificates (e.g. `certs/`).
33+
* The expected files inside this folder are typically `cert.pem` and `key.pem` or a custom CA used by pyproxy.
34+
* These files will be copied to `{{ pyproxy."method".install_path }}/certs/ca`.
35+
36+
For example for the docker method here are some variables :
37+
```yaml
38+
pyproxy:
39+
docker:
40+
ssl_inspect_ca_folder: "certs/"
41+
volumes:
42+
- source: /opt/pyproxy/certs/ca
43+
target: /app/certs/ca
44+
type: folder
45+
```
46+
Don't forget to add the CA volume for the "compose" and "docker" methods.
47+
48+
⚠️ If the variable `pyproxy.docker.ssl_inspect_ca_folder` is **not defined**, the certificate copy step is skipped automatically.
49+
50+
> The path is resolved relative to the role or playbook. Make sure the folder exists and is accessible during the playbook run.
51+
2852
## 📄 **License**
2953

3054
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

defaults/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ pyproxy:
1818
- source: /opt/pyproxy/config.ini
1919
target: /app/config.ini
2020
type: file
21+
# - source: /opt/pyproxy/certs/ca
22+
# target: /app/certs/ca
23+
# type: folder
2124
environment:
2225
- name: PYPROXY_DEBUG
2326
value: "True"
27+
# ssl_inspect_ca_folder: certs/
2428

2529
# Docker
2630
docker:
@@ -38,16 +42,21 @@ pyproxy:
3842
- source: /opt/pyproxy/config.ini
3943
target: /app/config.ini
4044
type: file
45+
# - source: /opt/pyproxy/certs/ca
46+
# target: /app/certs/ca
47+
# type: folder
4148
environment:
4249
- name: PYPROXY_DEBUG
4350
value: "True"
51+
# ssl_inspect_ca_folder: certs/
4452

4553
# Source
4654
source:
4755
repo: "https://github.com/6C656C65/pyproxy.git"
4856
install_path: "/opt/pyproxy"
4957
venv_path: "/opt/pyproxy/venv"
5058
service_name: "pyproxy"
59+
ssl_inspect_ca_folder: certs/
5160

5261
# These variables configure the config.ini file that will be copied to the machine.
5362
# You must configure either a volume for the "compose" or "docker" method, or an argument for the "source" method.

tasks/install_from_compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525
mode: "{{ '0755' if item.type == 'directory' else '0644' }}"
2626
loop: "{{ pyproxy.compose.volumes }}"
2727

28+
- name: Create the destination directory for SSL Inspection
29+
ansible.builtin.file:
30+
path: "{{ pyproxy.compose.install_path }}/certs/ca"
31+
state: directory
32+
mode: '0755'
33+
when: pyproxy.compose.ssl_inspect_ca_folder is defined
34+
35+
- name: Copy SSL certificate files if var is defined
36+
copy:
37+
src: "{{ pyproxy.compose.ssl_inspect_ca_folder }}/"
38+
dest: "{{ pyproxy.compose.install_path }}/certs/ca"
39+
owner: 1000
40+
group: 1000
41+
mode: "0600"
42+
when: pyproxy.compose.ssl_inspect_ca_folder is defined
43+
2844
- name: Pull the latest image using docker-compose
2945
ansible.builtin.command: docker-compose pull
3046
args:

tasks/install_from_docker.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
mode: "{{ '0755' if item.type == 'directory' else '0644' }}"
2525
loop: "{{ pyproxy.docker.volumes }}"
2626

27+
- name: Create the destination directory for SSL Inspection
28+
ansible.builtin.file:
29+
path: "{{ pyproxy.docker.install_path }}/certs/ca"
30+
state: directory
31+
mode: '0755'
32+
when: pyproxy.docker.ssl_inspect_ca_folder is defined
33+
34+
- name: Copy SSL certificate files if var is defined
35+
copy:
36+
src: "{{ pyproxy.docker.ssl_inspect_ca_folder }}/"
37+
dest: "{{ pyproxy.docker.install_path }}/certs/ca"
38+
owner: 1000
39+
group: 1000
40+
mode: "0600"
41+
when: pyproxy.docker.ssl_inspect_ca_folder is defined
42+
2743
- name: Run pyproxy container
2844
community.docker.docker_container:
2945
name: "{{ pyproxy.docker.name }}"

tasks/install_from_source.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@
4545
dest: "{{ pyproxy.source.install_path }}/config.ini"
4646
mode: '0644'
4747

48+
- name: Create the destination directory for SSL Inspection
49+
ansible.builtin.file:
50+
path: "{{ pyproxy.source.install_path }}/certs/ca"
51+
state: directory
52+
mode: '0755'
53+
when: pyproxy.source.ssl_inspect_ca_folder is defined
54+
55+
- name: Copy SSL certificate files if var is defined
56+
copy:
57+
src: "{{ pyproxy.source.ssl_inspect_ca_folder }}/"
58+
dest: "{{ pyproxy.source.install_path }}/certs/ca"
59+
owner: 1000
60+
group: 1000
61+
mode: "0600"
62+
when: pyproxy.source.ssl_inspect_ca_folder is defined
63+
4864
- name: Create a systemd service
4965
ansible.builtin.template:
5066
src: pyproxy.service

0 commit comments

Comments
 (0)