mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
In swarm mode the container_address lookup returns a $(/usr/bin/resolve-container-id ...) fragment that must expand at exec time; piping it through Jinja quote hands docker the literal string and every exec fails with 'No such container' (broke all three snipe-it CI variants). Remove the quote at the seven snipe-it sites and the live matrix/openproject sites, convert openproject's argv exec to shell so the fragment can expand, split the matrix bridge restart per deployment mode with a manager gate, and mark the compose-only or eval-contract sites with nocheck. A new lint (container-address-quote) bans the pattern repo-wide. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.6 KiB
YAML
42 lines
1.6 KiB
YAML
---
|
|
- name: "🔎 Check if Snipe-IT admin user already exists (by username)"
|
|
ansible.builtin.shell: |
|
|
container exec -i \
|
|
-e APP_KEY="{{ SNIPE_IT_APP_KEY }}" \
|
|
{{ SNIPE_IT_CONTAINER_ADDRESS }} \
|
|
php -r '
|
|
require "vendor/autoload.php";
|
|
$app = require "bootstrap/app.php";
|
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
$exists = \App\Models\User::where("username", "{{ lookup('users', 'administrator').username }}")
|
|
->whereNull("deleted_at")
|
|
->exists();
|
|
exit($exists ? 0 : 1);
|
|
'
|
|
register: snipe_it_admin_exists
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: "📁 Create Snipe-IT administrator account"
|
|
ansible.builtin.shell: >
|
|
container exec -i
|
|
-e APP_KEY="{{ SNIPE_IT_APP_KEY }}"
|
|
{{ SNIPE_IT_CONTAINER_ADDRESS }}
|
|
php artisan snipeit:create-admin
|
|
--first_name "{{ lookup('users', 'administrator').firstname }}"
|
|
--last_name "{{ lookup('users', 'administrator').lastname }}"
|
|
--username "{{ lookup('users', 'administrator').username }}"
|
|
--email "{{ lookup('users', 'administrator').email }}"
|
|
--password {{ lookup('users', 'administrator').password | quote }}
|
|
--no-interaction
|
|
when: snipe_it_admin_exists.rc != 0
|
|
register: snipe_it_admin_create
|
|
changed_when: "'New user created' in snipe_it_admin_create.stdout"
|
|
failed_when: >
|
|
snipe_it_admin_create.rc != 0
|
|
and not (
|
|
'Duplicate entry' in (snipe_it_admin_create.stderr | default(''))
|
|
and 'users_groups' in (snipe_it_admin_create.stderr | default(''))
|
|
)
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|