Skip agent deployment on Portainer host (ubuntu-server-01)
ubuntu-server-01 (10.40.40.2) runs Portainer itself and is already managed via local Docker socket (Portainer endpoint ID=3). Deploying a Portainer Agent there is redundant and port 9001 binding fails. Add portainer_skip_agent: true flag to the inventory and check it in both Play 2 (deploy agent) and Play 3 (register endpoint) to exclude the host from agent-based enrollment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d2cf626bee
commit
dc1efc5ae0
@ -14,6 +14,9 @@ all:
|
||||
ansible_user: sam
|
||||
ansible_ssh_pass: Lewiss4224@@@
|
||||
ansible_become_pass: Lewiss4224@@@
|
||||
# Portainer host — already in Portainer via local socket (ID=3).
|
||||
# Skip agent deployment; connecting via agent would be redundant.
|
||||
portainer_skip_agent: true
|
||||
|
||||
ubuntu-server-02:
|
||||
ansible_host: 10.40.40.3
|
||||
|
||||
@ -96,6 +96,10 @@
|
||||
ansible.builtin.meta: end_host
|
||||
when: not (docker_running | default(false))
|
||||
|
||||
- name: Skip hosts that are already managed by Portainer directly
|
||||
ansible.builtin.meta: end_host
|
||||
when: portainer_skip_agent | default(false)
|
||||
|
||||
- name: Check if portainer_agent container already exists
|
||||
ansible.builtin.command: >
|
||||
docker ps -a --filter name=portainer_agent --format "{% raw %}{{.Status}}{% endraw %}"
|
||||
@ -157,6 +161,10 @@
|
||||
ansible.builtin.meta: end_host
|
||||
when: not (docker_running | default(false))
|
||||
|
||||
- name: Skip hosts managed by Portainer directly (no agent needed)
|
||||
ansible.builtin.meta: end_host
|
||||
when: portainer_skip_agent | default(false)
|
||||
|
||||
- name: Check if endpoint already exists in Portainer
|
||||
ansible.builtin.uri:
|
||||
url: "{{ portainer_url }}/api/endpoints"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user