feat(openldap): add ansible role for deployment
This commit is contained in:
@ -25,3 +25,4 @@ tags:
|
|||||||
- nginx
|
- nginx
|
||||||
- restic
|
- restic
|
||||||
- user_management
|
- user_management
|
||||||
|
- openldap
|
||||||
|
3
roles/openldap/README.md
Normal file
3
roles/openldap/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# `finallycoffee.base.openldap` ansible role
|
||||||
|
|
||||||
|
Deploy and configure [OpenLDAP](https://www.openldap.org/).
|
40
roles/openldap/defaults/main/container.yml
Normal file
40
roles/openldap/defaults/main/container.yml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
openldap_container_name: "openldap"
|
||||||
|
openldap_container_image_registry: ~
|
||||||
|
openldap_container_image_namespace: ~
|
||||||
|
openldap_container_image_name: "openldap"
|
||||||
|
openldap_container_image_tag: ~
|
||||||
|
openldap_container_image_source: "pull"
|
||||||
|
openldap_container_image_force_source: >-2
|
||||||
|
{{ openldap_container_image_tag | default(false, true) }}
|
||||||
|
openldap_container_image_repository: >-2
|
||||||
|
{{
|
||||||
|
[
|
||||||
|
openldap_container_image_registry | default([], true),
|
||||||
|
openldap_container_image_namespace | default([], true),
|
||||||
|
openldap_container_image_name
|
||||||
|
] | flatten | join('/')
|
||||||
|
}}
|
||||||
|
openldap_container_image: >-2
|
||||||
|
{{
|
||||||
|
[
|
||||||
|
openldap_container_image_repository,
|
||||||
|
openldap_container_image_tag
|
||||||
|
| default(openldap_package_version, true),
|
||||||
|
] | join(':')
|
||||||
|
}}
|
||||||
|
openldap_container_env: ~
|
||||||
|
openldap_container_user: ~
|
||||||
|
openldap_container_ports: ~
|
||||||
|
openldap_container_labels: ~
|
||||||
|
openldap_container_volumes: ~
|
||||||
|
openldap_container_networks: ~
|
||||||
|
openldap_container_network_mode: ~
|
||||||
|
openldap_container_dns_servers: ~
|
||||||
|
openldap_container_etc_hosts: ~
|
||||||
|
openldap_container_memory: ~
|
||||||
|
openldap_container_memory_swap: ~
|
||||||
|
openldap_container_memory_reservation: ~
|
||||||
|
openldap_container_restart_policy: "on-failure"
|
||||||
|
openldap_container_state: >-2
|
||||||
|
{[ (openldap_state == 'present') | ternary('started', 'absent') }}
|
12
roles/openldap/defaults/main/main.yml
Normal file
12
roles/openldap/defaults/main/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
openldap_version: "2.6.8"
|
||||||
|
openldap_alpine_revision: "0"
|
||||||
|
openldap_alpine_package_version: >-2
|
||||||
|
{{ openldap_version }}-r{{ openldap_alpine_revision | string }}
|
||||||
|
|
||||||
|
openldap_config_path: "/etc/openldap/"
|
||||||
|
openldap_data_path: "/var/lib/openldap"
|
||||||
|
openldap_socket_path: "/run/openldap"
|
||||||
|
|
||||||
|
openldap_state: "present"
|
||||||
|
openldap_deployment_method: "docker"
|
0
roles/openldap/tasks/configure.yml
Normal file
0
roles/openldap/tasks/configure.yml
Normal file
29
roles/openldap/tasks/deploy-docker.yml
Normal file
29
roles/openldap/tasks/deploy-docker.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure container image '{{ openldap_container_image }}' is {{ openldap_state }}
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: "{{ openldap_container_image }}"
|
||||||
|
state: "{{ openldap_state }}"
|
||||||
|
source: "{{ openldap_container_image_source }}"
|
||||||
|
force_source: "{{ openldap_container_image_force_source }}"
|
||||||
|
|
||||||
|
- name: Ensure container '{{ openldap_container_name }}' is {{ openldap_container_state }}
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: "{{ openldap_container_name }}"
|
||||||
|
image: "{{ openldap_container_image }}"
|
||||||
|
env: "{{ openldap_container_env | default(omit, true) }}"
|
||||||
|
user: "{{ openldap_container_user | default(omit, true) }}"
|
||||||
|
ports: "{{ openldap_container_ports | default(omit, true) }}"
|
||||||
|
labels: "{{ openldap_container_labels | default(omit, true) }}"
|
||||||
|
volumes: "{{ openldap_container_volumes | default(omit, true) }}"
|
||||||
|
networks: "{{ openldap_container_networks | default(omit, true) }}"
|
||||||
|
network_mode: "{{ openldap_container_network_mode | default(omit, true) }}"
|
||||||
|
dns_servers: "{{ openldap_container_dns_servers | default(omit, true) }}"
|
||||||
|
etc_hosts: "{{ openldap_container_etc_hosts | default(omit, true) }}"
|
||||||
|
memory: "{{ openldap_container_memory | default(omit, true) }}"
|
||||||
|
memory_swap: "{{ openldap_container_memory_swap | default(omit, true) }}"
|
||||||
|
memory_reservation: >-2
|
||||||
|
{{ openldap_container_memory_reservation | default(omit, true) }}
|
||||||
|
restart_policy: >-2
|
||||||
|
{{ openldap_container_restart_policy | default(omit, true) }}
|
||||||
|
state: "{{ openldap_container_state }}"
|
||||||
|
|
22
roles/openldap/tasks/main.yml
Normal file
22
roles/openldap/tasks/main.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Check if 'openldap_state' is valid
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: >-2
|
||||||
|
Invalid state '{{ openldap_state }}'!
|
||||||
|
Supported states are {{ openldap_states | join(', ') }}.
|
||||||
|
when: openldap_state not in openldap_states
|
||||||
|
|
||||||
|
- name: Check if 'openldap_deployment_method' is valid
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: >-2
|
||||||
|
Invalid state '{{ openldap_deployment_method }}'!
|
||||||
|
Supported states are {{ openldap_deployment_methods | join(', ') }}.
|
||||||
|
when: openldap_deployment_method not in openldap_deployment_methods
|
||||||
|
|
||||||
|
- name: Ensure openldap is configured
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: "configure.yml"
|
||||||
|
|
||||||
|
- name: Ensure openldap is deployed using {{ openldap_deployment_method }}
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: "deploy-{{ openldap_deployment_method }}.yml"
|
6
roles/openldap/vars/main.yml
Normal file
6
roles/openldap/vars/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
openldap_states:
|
||||||
|
- "present"
|
||||||
|
- "absent"
|
||||||
|
openldap_deployment_methods:
|
||||||
|
- "docker"
|
Reference in New Issue
Block a user