mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-12-09 10:56:01 +00:00
This commit updates multiple roles to ensure compatibility with Ansible 2.20. Several include paths and task-loading mechanisms required adjustments, as Ansible 2.20 applies stricter evaluation rules for complex Jinja expressions and no longer resolves certain relative include paths the way Ansible 2.18 did. Key changes: - Replaced legacy once_finalize.yml and once_flag.yml with the new structure under tasks/utils/once/finalize.yml and tasks/utils/once/flag.yml. - Updated all include_tasks statements to use 'path_join' with playbook_dir, ensuring deterministic and absolute file resolution across roles. - Fixed all network helper includes by converting direct relative paths such as 'roles/docker-compose/tasks/utils/network.yml' to proper Jinja-evaluated paths. - Normalized MATOMO_* variable names for consistency with the updated variable scope behavior in Ansible 2.20. - Removed deprecated patterns that were implicitly supported in Ansible 2.18 but break under the more strict variable and path resolution model in 2.20. These changes are part of the full migration step required to ensure the infinito-nexus roles remain stable, deterministic, and forward-compatible with Ansible 2.20. Details of the discussion and reasoning can be found in this conversation: https://chatgpt.com/share/69300a8d-24d4-800f-bec0-e895a695618a
85 lines
3.3 KiB
YAML
85 lines
3.3 KiB
YAML
# @See https://raw.githubusercontent.com/snipe/snipe-it/master/app/Models/Setting.php
|
|
---
|
|
- name: "Wait until the Snipe-IT Login is available"
|
|
uri:
|
|
url: "{{ SNIPE_IT_URL }}/login"
|
|
method: GET
|
|
return_content: no
|
|
status_code: 200
|
|
register: snipeit_admin_check
|
|
retries: 30
|
|
delay: 5
|
|
until: snipeit_admin_check.status == 200
|
|
when: not ( applications | get_app_conf(application_id, 'features.oauth2', False))
|
|
|
|
- name: "Set all LDAP settings via Laravel Setting model (inside container as {{ SNIPE_IT_USER }})"
|
|
shell: |
|
|
docker-compose exec -T \
|
|
-e APP_KEY='{{ applications | get_app_conf(application_id, 'credentials.app_key', True) }}' \
|
|
-e XDG_CONFIG_HOME=/tmp \
|
|
-u {{ SNIPE_IT_USER }} application \
|
|
sh -c 'php artisan tinker << "EOF"
|
|
$s = \App\Models\Setting::getSettings();
|
|
$s->ldap_enabled = 1;
|
|
$s->ldap_server = "{{ LDAP.SERVER.URI }}";
|
|
$s->ldap_port = {{ LDAP.SERVER.PORT }};
|
|
$s->ldap_uname = "{{ LDAP.DN.ADMINISTRATOR.DATA }}";
|
|
$s->ldap_basedn = "{{ LDAP.DN.OU.USERS }}";
|
|
$s->ldap_filter = "&(objectClass=inetOrgPerson)";
|
|
$s->ldap_username_field = "{{ LDAP.USER.ATTRIBUTES.ID }}";
|
|
$s->ldap_fname_field = "{{ LDAP.USER.ATTRIBUTES.FIRSTNAME }}";
|
|
$s->ldap_lname_field = "{{ LDAP.USER.ATTRIBUTES.SURNAME }}";
|
|
$s->ldap_auth_filter_query = "uid=";
|
|
$s->ldap_version = 3;
|
|
$s->ldap_pw_sync = 0;
|
|
$s->is_ad = 0;
|
|
$s->ad_domain = "";
|
|
$s->ldap_default_group = "";
|
|
$s->ldap_email = "{{ LDAP.USER.ATTRIBUTES.MAIL }}";
|
|
$s->custom_forgot_pass_url = "{{ OIDC.CLIENT.RESET_CREDENTIALS }}";
|
|
$s->save();
|
|
EOF'
|
|
args:
|
|
chdir: "{{ docker_compose.directories.instance }}"
|
|
register: ldap_tinker
|
|
failed_when: >
|
|
ldap_tinker.stdout_lines is not defined
|
|
or ldap_tinker.stdout_lines[0] != '= true'
|
|
changed_when: >
|
|
ldap_tinker.stdout_lines is defined
|
|
and ldap_tinker.stdout_lines[0] == '= true'
|
|
notify: docker compose up
|
|
|
|
- name: Encrypt & save LDAP bind password via Crypt + DB façade
|
|
shell: |
|
|
docker-compose exec -T \
|
|
-u {{ SNIPE_IT_USER }} \
|
|
-e APP_KEY="{{ applications | get_app_conf(application_id, 'credentials.app_key', True) }}" \
|
|
-e XDG_CONFIG_HOME=/tmp \
|
|
application \
|
|
php artisan tinker --execute="
|
|
use Illuminate\Support\Facades\Crypt;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/* encrypt the clear-text password */
|
|
\$encrypted = Crypt::encrypt('{{ LDAP.BIND_CREDENTIAL }}');
|
|
|
|
/* write it straight into settings.ldap_pword */
|
|
/* update the one and only row in `settings` */
|
|
DB::table('settings')->update([
|
|
'ldap_pword' => \$encrypted
|
|
]);
|
|
echo 'Stored: ' . \$encrypted . PHP_EOL;
|
|
"
|
|
args:
|
|
chdir: "{{ docker_compose.directories.instance }}"
|
|
register: ldap_encrypt
|
|
failed_when: ldap_encrypt.rc != 0
|
|
|
|
- name: "Clear Laravel config & cache (inside container as {{ SNIPE_IT_USER }})"
|
|
shell: |
|
|
docker-compose exec -T -u {{ SNIPE_IT_USER }} application php artisan config:clear
|
|
docker-compose exec -T -u {{ SNIPE_IT_USER }} application php artisan cache:clear
|
|
args:
|
|
chdir: "{{ docker_compose.directories.instance }}"
|
|
notify: docker compose up |