Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Changelog

### Bug Fixes

- Use ansible_os_family in template (#133)
- Use ansible_facts["os_family"] in template (#133)

### Other Changes

Expand Down
4 changes: 2 additions & 2 deletions README-ostree.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Usage:
.ostree/get_ostree_data.sh packages runtime DISTRO-VERSION FORMAT
```

`DISTRO-VERSION` is in the format that Ansible uses for `ansible_distribution`
and `ansible_distribution_version` - for example, `Fedora-38`, `CentOS-8`,
`DISTRO-VERSION` is in the format that Ansible uses for `ansible_facts["distribution"]`
and `ansible_facts["distribution_version"]` - for example, `Fedora-38`, `CentOS-8`,
`RedHat-9.4`

`FORMAT` is one of `toml`, `json`, `yaml`, `raw`
Expand Down
14 changes: 10 additions & 4 deletions tests/inventory.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ all:
ansible_connection: local
ansible_host: localhost
{% else %}
{% for key in ["ansible_all_ipv4_addresses", "ansible_all_ipv6_addresses",
"ansible_default_ipv4", "ansible_default_ipv6", "ansible_host",
"ansible_port", "ansible_ssh_common_args",
"ansible_ssh_private_key_file","ansible_user"] %}
{# Facts - these are accessed via ansible_facts and written with legacy key names #}
{% for key in ['all_ipv4_addresses', 'all_ipv6_addresses',
'default_ipv4', 'default_ipv6'] %}
{% if key in hostvars[inventory_hostname]['ansible_facts'] %}
ansible_{{ key }}: {{ hostvars[inventory_hostname]['ansible_facts'][key] }}
{% endif %}
{% endfor %}
{# Connection variables - these are accessed directly #}
{% for key in ['ansible_host', 'ansible_port', 'ansible_ssh_common_args',
'ansible_ssh_private_key_file', 'ansible_user'] %}
{% if key in hostvars[inventory_hostname] %}
{{ key }}: {{ hostvars[inventory_hostname][key] }}
{% endif %}
Expand Down
20 changes: 10 additions & 10 deletions tests/tests_ssh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
# to itself.
kdump_test_ssh_server_outside: "{{ inventory_hostname }}"
kdump_test_ssh_source: "{{
ansible_env['SSH_CONNECTION'].split()[0]
if 'SSH_CONNECTION' in ansible_env
ansible_facts['env']['SSH_CONNECTION'].split()[0]
if 'SSH_CONNECTION' in ansible_facts['env']
else '127.0.0.1' }}"

# this is the address at which the ssh dump server can be reached
# from the managed host. Dumps will be uploaded there.
kdump_test_ssh_server_inside: >-
{{
kdump_test_ssh_source if kdump_test_ssh_source in
hostvars[kdump_test_ssh_server_outside]['ansible_all_ipv4_addresses']
+ hostvars[kdump_test_ssh_server_outside]['ansible_all_ipv6_addresses']
hostvars[kdump_test_ssh_server_outside]['ansible_facts']['all_ipv4_addresses']
+ hostvars[kdump_test_ssh_server_outside]['ansible_facts']['all_ipv6_addresses']
else
hostvars[kdump_test_ssh_server_outside]['ansible_default_ipv4']['address']
hostvars[kdump_test_ssh_server_outside]['ansible_facts']['default_ipv4']['address']
}}

# This is the outside address. Ansible will connect to it to
# copy the ssh key.
kdump_ssh_server: "{{ kdump_test_ssh_server_outside }}"
kdump_ssh_user: >-
{{ hostvars[kdump_test_ssh_server_outside]['ansible_user_id'] }}
{{ hostvars[kdump_test_ssh_server_outside]['ansible_facts']['user_id'] }}
kdump_path: /tmp/tests_ssh
kdump_target:
type: ssh
Expand Down Expand Up @@ -65,17 +65,17 @@
debug:
msg: Skipping the test on EL 6 when storing logs over ssh to localhost
when:
- ansible_distribution in ['CentOS','RedHat']
- ansible_distribution_major_version == '6'
- ansible_facts['distribution'] in ['CentOS','RedHat']
- ansible_facts['distribution_major_version'] == '6'
- kdump_test_ssh_server_outside == inventory_hostname

# The skip is required on EL 6 because mkdumprd on EL 6 does not work when
# configuring ssh to localhost
- name: Skip the test on EL 6 when control node == managed node
meta: end_host
when:
- ansible_distribution in ['CentOS','RedHat']
- ansible_distribution_major_version == '6'
- ansible_facts['distribution'] in ['CentOS','RedHat']
- ansible_facts['distribution_major_version'] == '6'
- kdump_test_ssh_server_outside == inventory_hostname

- name: >-
Expand Down
18 changes: 9 additions & 9 deletions tests/tests_ssh_reboot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
# to itself.
kdump_test_ssh_server_outside: "{{ inventory_hostname }}"
kdump_test_ssh_source: "{{
ansible_env['SSH_CONNECTION'].split()[0]
if 'SSH_CONNECTION' in ansible_env
ansible_facts['env']['SSH_CONNECTION'].split()[0]
if 'SSH_CONNECTION' in ansible_facts['env']
else '127.0.0.1' }}"

# this is the address at which the ssh dump server can be reached
# from the managed host. Dumps will be uploaded there.
kdump_test_ssh_server_inside: >-
{{
kdump_test_ssh_source if kdump_test_ssh_source in
hostvars[kdump_test_ssh_server_outside]['ansible_all_ipv4_addresses']
+ hostvars[kdump_test_ssh_server_outside]['ansible_all_ipv6_addresses']
hostvars[kdump_test_ssh_server_outside]['ansible_facts']['all_ipv4_addresses']
+ hostvars[kdump_test_ssh_server_outside]['ansible_facts']['all_ipv6_addresses']
else
hostvars[kdump_test_ssh_server_outside]['ansible_default_ipv4']['address']
hostvars[kdump_test_ssh_server_outside]['ansible_facts']['default_ipv4']['address']
}}

# This is the outside address. Ansible will connect to it to
Expand Down Expand Up @@ -82,17 +82,17 @@
debug:
msg: Skipping the test on EL 6 because control node == managed node
when:
- ansible_distribution in ['CentOS','RedHat']
- ansible_distribution_major_version == '6'
- ansible_facts['distribution'] in ['CentOS','RedHat']
- ansible_facts['distribution_major_version'] == '6'
- kdump_test_ssh_server_outside == inventory_hostname

# The skip is required on EL 6 because mkdumprd on EL 6 does not work when
# configuring ssh to localhost
- name: Skip the test on EL 6 when control node == managed node
meta: end_host
when:
- ansible_distribution in ['CentOS','RedHat']
- ansible_distribution_major_version == '6'
- ansible_facts['distribution'] in ['CentOS','RedHat']
- ansible_facts['distribution_major_version'] == '6'
- kdump_test_ssh_server_outside == inventory_hostname

- name: Determine if system is ostree and set flag
Expand Down
4 changes: 2 additions & 2 deletions tests/vars/rh_distros_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __kdump_rh_distros:
__kdump_rh_distros_fedora: "{{ __kdump_rh_distros + ['Fedora'] }}"

# Use this in conditionals to check if distro is Red Hat or clone
__kdump_is_rh_distro: "{{ ansible_distribution in __kdump_rh_distros }}"
__kdump_is_rh_distro: "{{ ansible_facts['distribution'] in __kdump_rh_distros }}"

# Use this in conditionals to check if distro is Red Hat or clone, or Fedora
__kdump_is_rh_distro_fedora: "{{ ansible_distribution in __kdump_rh_distros_fedora }}"
__kdump_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __kdump_rh_distros_fedora }}"
4 changes: 2 additions & 2 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ __kdump_rh_distros:
__kdump_rh_distros_fedora: "{{ __kdump_rh_distros + ['Fedora'] }}"

# Use this in conditionals to check if distro is Red Hat or clone
__kdump_is_rh_distro: "{{ ansible_distribution in __kdump_rh_distros }}"
__kdump_is_rh_distro: "{{ ansible_facts['distribution'] in __kdump_rh_distros }}"

# Use this in conditionals to check if distro is Red Hat or clone, or Fedora
__kdump_is_rh_distro_fedora: "{{ ansible_distribution in __kdump_rh_distros_fedora }}"
__kdump_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __kdump_rh_distros_fedora }}"
# END - DO NOT EDIT THIS BLOCK - rh distros variables

__kdump_service: kdump
Expand Down
Loading