mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 18:29:21 +00:00 
			
		
		
		
	Finished listmonk bounce implementation
This commit is contained in:
		| @@ -23,7 +23,7 @@ | ||||
| - name: "Fetch existing API tokens via curl inside admin container" | ||||
|   command: >- | ||||
|     docker compose exec -T admin \ | ||||
|       curl -s -X GET http://127.0.0.1:8080/api/v1/token \ | ||||
|       curl -s -X GET {{ mailu_api_base_url }}/token \ | ||||
|         -H "Authorization: Bearer {{ mailu_global_api_token }}" | ||||
|   args: | ||||
|     chdir: "{{ mailu_compose_dir }}" | ||||
| @@ -41,10 +41,23 @@ | ||||
|            | list | ||||
|          ).0 | default(None) }} | ||||
|  | ||||
| - name: "Create API token for {{ mailu_user }} if none exists" | ||||
| - name: "Delete existing API token for {{ mailu_user }} if local token missing but remote exists" | ||||
|   command: >- | ||||
|     docker compose exec -T admin \ | ||||
|       curl -s -X POST http://127.0.0.1:8080/api/v1/token \ | ||||
|       curl -s -X DELETE {{ mailu_api_base_url }}/token/{{ mailu_user_existing_token.id }} \ | ||||
|         -H "Authorization: Bearer {{ mailu_global_api_token }}" | ||||
|   args: | ||||
|     chdir: "{{ mailu_compose_dir }}" | ||||
|   when: | ||||
|     - users[mailu_user].mailu_token is not defined | ||||
|     - mailu_user_existing_token is not none | ||||
|   register: mailu_token_delete | ||||
|   changed_when: mailu_token_delete.rc == 0 | ||||
|  | ||||
| - name: "Create API token for {{ mailu_user }} if no local token defined" | ||||
|   command: >- | ||||
|     docker compose exec -T admin \ | ||||
|       curl -s -X POST {{ mailu_api_base_url }}/token \ | ||||
|         -H "Authorization: Bearer {{ mailu_global_api_token }}" \ | ||||
|         -H "Content-Type: application/json" \ | ||||
|         -d '{{ { | ||||
| @@ -54,10 +67,11 @@ | ||||
|             } | to_json }}' | ||||
|   args: | ||||
|     chdir: "{{ mailu_compose_dir }}" | ||||
|   when: users[mailu_user].mailu_token is not defined | ||||
|   register: mailu_token_creation | ||||
|   when: (mailu_user_existing_token | default('') | length) == 0 | ||||
|   changed_when: mailu_token_creation.rc == 0 | ||||
|  | ||||
| - name: "Add mailu_token to users dict if created" | ||||
| - name: "Set mailu_token for {{ mailu_user }} in users dict if newly created" | ||||
|   set_fact: | ||||
|     users: >- | ||||
|       {{ users | ||||
| @@ -70,6 +84,4 @@ | ||||
|              ) | ||||
|            }, recursive=True) | ||||
|       }} | ||||
|   when: | ||||
|     - mailu_token_creation is defined | ||||
|     - (mailu_user_existing_token | default('') | length) == 0 | ||||
|   when: users[mailu_user].mailu_token is not defined | ||||
|   | ||||
| @@ -31,7 +31,7 @@ | ||||
|   vars: | ||||
|     mailu_compose_dir:        "{{ docker_compose.directories.instance }}" | ||||
|     mailu_domain:             "{{ primary_domain }}" | ||||
|     mailu_api_base_url:       "{{ web_protocol }}://{{ domain }}/api/v1" | ||||
|     mailu_api_base_url:       "http://127.0.0.1:8080/api/v1" | ||||
|     mailu_global_api_token:   "{{ applications.mailu.credentials.api_token }}" | ||||
|     mailu_action:             "{{ item.value.is_admin | default(false) | ternary('admin','user') }}" | ||||
|     mailu_user:               "{{ item.key }}" | ||||
|   | ||||
| @@ -8,3 +8,9 @@ | ||||
|     name: cleanup-docker-anonymous-volumes | ||||
|   when: mode_cleanup | bool | ||||
|  | ||||
| - name: "Show User Configuration (Important when mailu tokens are created automatic)" | ||||
|   debug: | ||||
|     msg: | ||||
|       users: "{{users}}" | ||||
|   when: enable_debug | bool | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user