-
Bug
-
Resolution: Unresolved
-
Undefined
-
None
-
rhel-system-roles-1.120.1-0.1.el10
-
None
-
Low
-
rhel-system-roles
-
0
-
Dev ack
-
False
-
False
-
-
Yes
-
Red Hat Enterprise Linux
-
None
-
Requested
-
None
-
Enhancement
-
-
Proposed
-
Unspecified
-
Unspecified
-
Unspecified
-
None
Hi,
When im trying to use role in "Managed-host-to-unmanaged-host (e.g. remote is appliance)" mode Ansible throws error:
>
> [ERROR]: Task failed: object of type 'dict' has no attribute '1.1.1.1'
>
> Task failed.
> Origin: /Users/raf/.ansible/roles/linux-system-roles.vpn/tasks/main.yml:131:7
>
> 129 flatten | reject('match', '^' ~ inventory_hostname ~ '$') | unique | list }}"
> 130 block:
> 131 - name: Create ipsec.conf files
> ^ column 7
>
> <<< caused by >>>
>
> object of type 'dict' has no attribute '1.1.1.1'
> Origin: /Users/raf/.ansible/roles/linux-system-roles.vpn/templates/libreswan-host-to-host.conf.j2
>
> failed: [vrinfrchnexus01] (item=krk) =>
>
Host vrinfrchnexus01 is included in inventory and krk is not and variables are set as follow:
```
vpn_connections:
- auth_method: psk
auto: ignore
shared_key_content: nnuxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
type: tunnel
hosts:
vrinfrchnexus01:
hostname: 1.1.1.1
leftid: leftidhost
krk:
hostname: 2.2.2.2
rightid: rightidhost
subnets: - 10.10.0.0/16
```
I asked AI to analyse main.yml and template and proposed solution worked rendering proper ipsec.conf
```
+#
+# Ansible managed
+#
+# system_role:vpn
+
+conn 1.1.1.1-to-2.2.2.2
+ left=1.1.1.1
+ leftid=leftidhost
+ right=2.2.2.2
+ rightid=rightidhost
+ rightsubnets=
+ ikev2=insist
+ auto=ignore
+ type=tunnel
+ authby=secret
```
Fixed template code:
```
conn {{ tunnel.name ~ '' if 'name' in tunnel and tunnel.name else '' }}{{ host }}-to{{ otherhost }}
left={{ host }}
leftid={{ host | vpn_ipaddr | ternary('','@') }}{{ leftid }}
leftsubnets=
{ {%- for subnet in tunnel.hosts[thishost].subnets -%}{{ subnet }}
{%- if not loop.last -%},
{%- endif -%} {%- endfor -%}}
{% endif %} {# --- FIX END--- #} {% endif %} {% endfor %}```
Could you verify fix and apply to main?
Regards
RafaĆ
- links to
-
RHEA-2025:155382
rhel-system-roles bug fix and enhancement update