mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 22:37:29 +00:00
feat(pip): add global_install flag and fix python-ldap installation for Ansible interpreter
- Add global_install flag to sys-pip-install role (default: false) - Allow optional system-wide installs via pip3 with --break-system-packages - Install python-ldap via pip in Ansible interpreter for OpenLDAP role - Refactor svc-db-openldap tasks into 01_core.yml with run-once gating - Fix environment handling for conditional global pip installs - Enable global pip installs for CLI tools (gitcon, ldapsm, backup tools, cleanup tools) https://chatgpt.com/share/6963dd5d-cae0-800f-b8d7-82a3808be634
This commit is contained in:
13 files changed
+100
-89
No files matched your search
@@ -9,6 +9,7 @@
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: gitcon
|
||||
global_install: true
|
||||
|
||||
- when: run_once_desk_git is not defined
|
||||
block:
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
- name: "Setup docker network for {{ application_id }}"
|
||||
include_tasks: "{{ [playbook_dir, 'roles/docker-compose/tasks/utils/network.yml' ] | path_join }}"
|
||||
vars:
|
||||
docker_network_name: "{{ OPENLDAP_NETWORK }}"
|
||||
docker_network_subnet: "{{ networks.local[application_id].subnet }}"
|
||||
|
||||
- name: Create {{ domains | get_domain(application_id) }}.conf if LDAP is exposed to internet
|
||||
template:
|
||||
src: "nginx.stream.conf.j2"
|
||||
dest: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
|
||||
notify: restart openresty
|
||||
when: OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
|
||||
|
||||
- name: Remove {{ domains | get_domain(application_id) }}.conf if LDAP is not exposed to internet
|
||||
file:
|
||||
path: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
|
||||
state: absent
|
||||
when: not OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
|
||||
|
||||
- name: "Wait for LDAP to be available"
|
||||
wait_for:
|
||||
host: "{{ DOCKER_REACH_HOST }}"
|
||||
port: "{{ ports.localhost.ldap[application_id] }}"
|
||||
delay: 5
|
||||
timeout: 120
|
||||
state: started
|
||||
|
||||
- name: "Reset LDAP Credentials"
|
||||
include_tasks: 02_credentials.yml
|
||||
when:
|
||||
- OPENLDAP_NETWORK_SWITCH_LOCAL | bool
|
||||
- OPENLDAP_PROVISION_CREDENTIALS | bool
|
||||
|
||||
- name: "create directory {{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
file:
|
||||
path: "{{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop: "{{ OPENLDAP_LDIF_TYPES }}"
|
||||
|
||||
- name: "Import LDIF Configuration"
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- configuration
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: OPENLDAP_PROVISION_CONFIGURATION | bool
|
||||
|
||||
- name: flush LDIF handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Ensure python-ldap is installed for the Ansible interpreter
|
||||
include_role:
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: python-ldap
|
||||
|
||||
- name: "Include Schemas (if enabled)"
|
||||
include_tasks: 03_schemas.yml
|
||||
when: OPENLDAP_PROVISION_SCHEMAS | bool
|
||||
|
||||
- name: "Import LDAP Entries (if enabled)"
|
||||
include_tasks: 04_users.yml
|
||||
when: OPENLDAP_PROVISION_USERS | bool
|
||||
|
||||
- name: "Import LDIF Data (if enabled)"
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- groups
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: OPENLDAP_PROVISION_GROUPS | bool
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- name: "Add Objects to all users"
|
||||
include_tasks: 05_update.yml
|
||||
when: OPENLDAP_PROVISION_UPDATE | bool
|
||||
|
||||
- include_tasks: utils/once/flag.yml
|
||||
File renamed without changes.
+1
@@ -3,6 +3,7 @@
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: ldapsm
|
||||
global_install: true
|
||||
|
||||
- name: "Include Nextcloud Schema"
|
||||
include_tasks: schemas/nextcloud.yml
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,79 +1,3 @@
|
||||
---
|
||||
- name: "Setup docker network for {{ application_id }}"
|
||||
include_tasks: "{{ [playbook_dir, 'roles/docker-compose/tasks/utils/network.yml' ] | path_join }}"
|
||||
vars:
|
||||
docker_network_name: "{{ OPENLDAP_NETWORK }}"
|
||||
docker_network_subnet: "{{ networks.local[application_id].subnet }}"
|
||||
|
||||
- name: Create {{ domains | get_domain(application_id) }}.conf if LDAP is exposed to internet
|
||||
template:
|
||||
src: "nginx.stream.conf.j2"
|
||||
dest: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
|
||||
notify: restart openresty
|
||||
when: OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
|
||||
|
||||
- name: Remove {{ domains | get_domain(application_id) }}.conf if LDAP is not exposed to internet
|
||||
file:
|
||||
path: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
|
||||
state: absent
|
||||
when: not OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
|
||||
|
||||
- name: "Wait for LDAP to be available"
|
||||
wait_for:
|
||||
host: "{{ DOCKER_REACH_HOST }}"
|
||||
port: "{{ ports.localhost.ldap[application_id] }}"
|
||||
delay: 5
|
||||
timeout: 120
|
||||
state: started
|
||||
|
||||
- name: "Reset LDAP Credentials"
|
||||
include_tasks: 01_credentials.yml
|
||||
when:
|
||||
- OPENLDAP_NETWORK_SWITCH_LOCAL | bool
|
||||
- OPENLDAP_PROVISION_CREDENTIALS | bool
|
||||
|
||||
- name: "create directory {{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
file:
|
||||
path: "{{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop: "{{ OPENLDAP_LDIF_TYPES }}"
|
||||
|
||||
- name: "Import LDIF Configuration"
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- configuration
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: OPENLDAP_PROVISION_CONFIGURATION | bool
|
||||
|
||||
- name: flush LDIF handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: install python-ldap
|
||||
package:
|
||||
name:
|
||||
- python-ldap
|
||||
state: present
|
||||
|
||||
- name: "Include Schemas (if enabled)"
|
||||
include_tasks: 02_schemas.yml
|
||||
when: OPENLDAP_PROVISION_SCHEMAS | bool
|
||||
|
||||
- name: "Import LDAP Entries (if enabled)"
|
||||
include_tasks: 03_users.yml
|
||||
when: OPENLDAP_PROVISION_USERS | bool
|
||||
|
||||
- name: "Import LDIF Data (if enabled)"
|
||||
include_tasks: _ldifs_creation.yml
|
||||
loop:
|
||||
- groups
|
||||
loop_control:
|
||||
loop_var: folder
|
||||
when: OPENLDAP_PROVISION_GROUPS | bool
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- name: "Add Objects to all users"
|
||||
include_tasks: 04_update.yml
|
||||
when: OPENLDAP_PROVISION_UPDATE | bool
|
||||
- include_tasks: 01_core.yml
|
||||
when: run_once_svc_db_openldap is not defined
|
||||
@@ -3,6 +3,7 @@
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: 'backup-docker-to-local==1.3.0'
|
||||
global_install: true
|
||||
|
||||
- name: Assert required baudolo commands are available
|
||||
ansible.builtin.command: "which {{ cmd_name }}"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: '{{ SYS_CTL_CLN_ANON_VOLUMES_COMMAND }}'
|
||||
global_install: true
|
||||
|
||||
- include_role:
|
||||
name: sys-service
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
name: sys-pip-install
|
||||
vars:
|
||||
package_name: '{{ CLEANUP_FAILED_BACKUPS_PKG }}'
|
||||
global_install: true
|
||||
|
||||
- include_role:
|
||||
name: sys-service
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# If the following variable is set to true it will be installed globally
|
||||
global_install: false
|
||||
@@ -9,9 +9,7 @@
|
||||
ansible.builtin.pip:
|
||||
name: "{{ package_name }}"
|
||||
state: latest
|
||||
executable: pip3
|
||||
extra_args: "--break-system-packages"
|
||||
environment:
|
||||
PIP_BREAK_SYSTEM_PACKAGES: "1"
|
||||
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
become: true
|
||||
executable: "{{'pip3' if global_install | bool else omit }}"
|
||||
extra_args: "{{'--break-system-packages' if global_install | bool else omit }}"
|
||||
environment: "{{ {'PIP_BREAK_SYSTEM_PACKAGES': '1', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'} if global_install | bool else omit }}"
|
||||
become: "{{ true if global_install | bool else false }}"
|
||||
@@ -1,4 +1,10 @@
|
||||
# run_once_sys_stk_back_stateful: disabled
|
||||
- name: "For '{{ application_id }}': Load OpenLDAP"
|
||||
include_role:
|
||||
name: svc-db-openldap
|
||||
when:
|
||||
- SYS_STK_BACK_STATEFULL_LDAP_ENABLED | bool
|
||||
- run_once_svc_db_openldap is not defined
|
||||
|
||||
- name: "For '{{ application_id }}': Set database_application_id (Needed due to lazzy loading issue)"
|
||||
set_fact:
|
||||
@@ -10,11 +16,6 @@
|
||||
- "{{ DOCKER_VARS_FILE }}" # Important to load docker variables first so that database can use them
|
||||
- "{{ DATABASE_VARS_FILE }}" # Important to load them before docker role so that backup can use them
|
||||
|
||||
- name: "For '{{ application_id }}': Load OpenLDAP"
|
||||
include_role:
|
||||
name: svc-db-openldap
|
||||
when: SYS_STK_BACK_STATEFULL_LDAP_ENABLED | bool
|
||||
|
||||
- name: "For '{{ application_id }}': Load central RDBMS"
|
||||
include_role:
|
||||
name: sys-svc-rdbms
|
||||
|
||||
Reference in new issue
Block a user