Increment number on each node with excluding one

44 Views Asked by At

I'm trying to automatically name node number in tomcat server.xml on several nodes. I have for that the playbook below:

vars:
  - node_number: "{{ ansible_host_all.index(inventory_hostname) + 1 }}"

- name: Nommage des nodes
  block:
    - name: Change interpreter
      set_fact:
        ansible_python_interpreter: "/usr/bin/python3"

- name: Nommage des nodes
      become: yes
      become_method: sudo
      become_user: "{{env}}adm"
      community.general.xml:
        path: /data/{{env}}/web/tomcat/conf/server.xml
        xpath: /Server/Service/Engine
        attribute: jvmroute
        value: "node0{{node_number}}"
        backup: true
  when:
    - ansible_facts['distribution'] == 'Rocky'

The problem is I have four nodes (BDD, APP1, APP2, APP3). With this playbook the node number start with BDD=node01 then APP1=node02 ...etc

What I am trying to do is to exclude BDD server from this task to start node number at APP1=node02 then APP2=node02 ...etc

Can you please help me?

0

There are 0 best solutions below