Jason,

Forgive my tardiness in replying.  Sickness has caused the delay.

Looking at the template (wildfly.properties.j2),  I will make a wild guess as to the issue.

There is a ansible_variable (not a user variable) known as inventory_hostname.  It is created by ansible when you begin execution of the role.  It is created in the Gathering Facts tasks that is auto-generated by ansible to execute as the first task in the execution of a role.

I'm unsure if the variable is derived from the hostnamectl command on the target host or if it is derived from the name in the hosts.yml file under the inventories directory.

The template having an issue is configure-properties.yml.   It is trying to determine which network interface to configure wildfly to use.

The computation relies on inventory_hostname being a fqdn.  Is the target hostname in your inventory file a fqdn?

Another possibility, is my logic may be assuming ipv4 addressing.  Perhaps your system is ipv6 addressed?

One last possibility is you have defined the target host to be on the same host as the ansible controller.  In which case the ansible task will not use any ipv4 or ipv6 to communicate between the target host and the ansible controller.  If that is the case, there may not be a SSH connection from which to determine the ipv4 address to use.

Hope that one of these ideas bears fruit.

Thanks for testing.  I appreciate your effort very much.

John Himpel
(recovering from the flu)

The variables that 
On Thu, 2022-12-29 at 22:55 +0000, J Beard wrote:
John,

I reworked my inventory to look like yours and same thing. Also, I think you need to update your github page. What I pulled down isn't updated to what you posted in this email chain. I'm going to look at few things later tonight. 
 
 TASK [wildfly_service : configure_properties wf26 - Configure standalone properties] ********************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: {{ hostvars[inventory_hostname]["ansible_env"].SSH_CONNECTION.split(" ")[2] }}: 'dict object' has no attribute 'SSH_CONNECTION'
fatal: [f36server1.iapetus.local]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: {{ hostvars[inventory_hostname][\"ansible_env\"].SSH_CONNECTION.split(\" \")[2] }}: 'dict object' has no attribute 'SSH_CONNECTION'"}


inventories
├── inventories/test
   ├── inventories/test/hosts.yml
   └── inventories/test/host_vars
       └── inventories/test/host_vars/f36server1.iapetus.local
           ├── inventories/test/host_vars/f36server1.iapetus.local/vars.yml
           └── inventories/test/host_vars/f36server1.iapetus.local/vault.yml





From: Jason Beard <jas_beard@hotmail.com>
Sent: Wednesday, December 28, 2022 5:21 PM
To: server@lists.fedoraproject.org <server@lists.fedoraproject.org>
Subject: Re: WildFly
 

I'll check the inventory stuff in a bit. Without looking I'm sure mine isn't setup like that. I'll have to fix that.

Task where it fails:

TASK [wildfly_service : configure_properties wf26 - Configure standalone properties]

On 12/28/22 12:46, John W. Himpel wrote:
On Wed, 2022-12-28 at 11:35 -0600, Jason Beard wrote:

Greetings! In regards to Wildfly below is the error I'm getting in the Ansible playbook run.

The error is in the jinja2 template.  I'm pretty sure I can update it a different way but I wasn't sure that the current setting is a necessity.  I'm an Ansible newbie so I tend to ask before I change things.

Let me know if you need any other information.

Thanks,

Jason


Error:

~~~

ansible.errors.AnsibleUndefinedVariable: {{ hostvars[inventory_hostname]["ansible_env"].SSH_CONNECTION.split(" ")[2] }}: 'dict object'has no attribute 'SSH_CONNECTION'

During handling of the above exception, another exception occurred:                   

Traceback (most recent call last):         
  File "/usr/lib/python3.8/site-packages/ansible/plugins/action/template.py", line 150, in run                                                                              
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)                                                               
  File "/usr/lib/python3.8/site-packages/ansible/template/__init__.py", line 1176, in do_template                                                                           
    raise AnsibleUndefinedVariable(e)      
ansible.errors.AnsibleUndefinedVariable: {{ hostvars[inventory_hostname]["ansible_env"].SSH_CONNECTION.split(" ")[2] }}: 'dict object' has no attribute 'SSH_CONNECTION'
fatal: [f36server1.iapetus.local]: FAILED! => {                                       
    "changed": false,                      
    "msg": "AnsibleUndefinedVariable: {{ hostvars[inventory_hostname][\"ansible_env\"].SSH_CONNECTION.split(\" \")[2] }}: 'dict object' has no attribute 'SSH_CONNECTION'"
}       

~~~


Jason,

Thanks for the report.  There are many tasks in the role that attempt to copy a templatized file to the ansible target host.  I believe I have supplied a name for each task that should display in the ansible.log file (if you have one) or on standard out.  It would be most useful if you could tell me the name on the task that is having the issue.

Without the above information, my best guess is your "inventories"  directory has an issue.  Mine looks like this:

ansible/
    inventories/
        hosts.yml
        host_vars/
            testWildfly.jlhimpel.net/
                vars.yml
                vault.yml

Where hosts.yml contains:
---
all:
  hosts:
    testWildfly.jlhimpel.net:
  children:
    allServersGroup:
      hosts:
        testWildfly.jlhimpel.net:
    wildflyAllRemoveGroup:
      hosts:
        testWildfly.jlhimpel.net:
     wildflyInstanceRemoveGroup:
      hosts:
        testWildfly.jlhimpel.net:
    wildflyServiceGroup:
      hosts:
        testWildfly.jlhimpel.net:
    wildflySslGroup:
      hosts:
        testWildfly.jlhimpel.net:
    wildflyVersionRemoveGroup:
      hosts:
        testWildfly.jlhimpel.net:
...

Where vars.yml contains:
---
# python version on this host
ansible_python_interpreter: /usr/bin/python3

# non sensitive data
firewall_mgr: firewalld
primary_net_interface: enp1s0

# sensitive data
ansible_ssh_user: "{{ vault_ansible_ssh_user }}"
ansible_ssh_pass: "{{ vault_ansible_ssh_pass }}"
ansible_become_pass: "{{ vault_ansible_become_pass }}"
...

Where vault.yml is an encrypted file containing:
---
vault_ansible_ssh_user: XXXXX
vault_ansible_ssh_pass: XXXXX
vault_ansible_become_pass: XXXXX
 (Of course, you will need to provide your local values for XXXXX).

Let me know if any of this helps.

John
...


                  


_______________________________________________
server mailing list -- server@lists.fedoraproject.org
To unsubscribe send an email to server-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/server@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue


_______________________________________________
server mailing list -- server@lists.fedoraproject.org
To unsubscribe send an email to server-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/server@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
_______________________________________________
server mailing list -- server@lists.fedoraproject.org
To unsubscribe send an email to server-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/server@lists.fedoraproject.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue