Uploaded image for project: 'Ansible Automation Platform RFEs'
  1. Ansible Automation Platform RFEs
  2. AAPRFE-1627

enforce inventory host order for positional notation

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Ansible-core runs hosts in the order they are in the inventory file allowing the use of positional notations like:

      fileserver:
         hosts:
              wpv-fs1: {}
              wpv-fs2: {}
              wpv-fs3: {}

       

      You would then be able to target the first host in the group like this:

       

      when: "groups.fileserver is defined and ansible_hostname == groups.fileserver.0"

       

      According to https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_strategies.html#ordering-execution-based-on-inventory

      this is no longer guaranteed to work in AAP:

      "the ‘inventory’ order does not equate to the order in which hosts/groups are defined in the inventory source file, but the ‘order in which a selection is returned from the compiled inventory’. This is a backwards compatible option and while reproducible it is not normally predictable. Due to the nature of inventory, host patterns, limits, inventory plugins and the ability to allow multiple sources, it is almost impossible to return such an order. For simple cases, this might happen to match the file definition order, but that is not guaranteed."

      We would like this to be changed so that order in the inventory and order of execution remains constant.

       

              bcoursen@redhat.com Brian Coursen
              rhn-support-gscarbor Gary Scarborough
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: