Skip to content

Commit 1f21b34

Browse files
committed
Fix INJECT_FACTS_AS_VARS deprecation warning
Ansible 2.18 deprecated accessing facts like `ansible_fqdn` directly, preferring `ansible_facts['fqdn']` instead. This will become an error in a future Ansible release. Updated fact references: - ansible_fqdn -> ansible_facts['fqdn'] - ansible_domain -> ansible_facts['domain'] - ansible_virtualization_role -> ansible_facts['virtualization_role'] - ansible_virtualization_type -> ansible_facts['virtualization_type'] See: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars
1 parent fa81fdd commit 1f21b34

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ None
1212
#### Variables
1313

1414
* `postfix_install` [default: `[postfix, mailutils, libsasl2-2, sasl2-bin, libsasl2-modules]`]: Packages to install
15-
* `postfix_hostname` [default: `{{ ansible_fqdn }}`]: Host name, used for `myhostname` and in `mydestination`
16-
* `postfix_mailname` [default: `{{ ansible_fqdn }}`]: Mail name (in `/etc/mailname`), used for `myorigin`
15+
* `postfix_hostname` [default: `{{ ansible_facts['fqdn'] }}`]: Host name, used for `myhostname` and in `mydestination`
16+
* `postfix_mailname` [default: `{{ ansible_facts['fqdn'] }}`]: Mail name (in `/etc/mailname`), used for `myorigin`
1717

1818
* `postfix_compatibility_level` [optional]: With backwards compatibility turned on (the compatibility_level value is less than the Postfix built-in value), Postfix looks for settings that are left at their implicit default value, and logs a message when a backwards-compatible default setting is required (e.g. `2`, `Postfix >= 3.0`)
1919

@@ -55,7 +55,7 @@ None
5555
* `postfix_smtpd_data_restrictions` [optional]: List of data restrictions ([see](http://www.postfix.org/postconf.5.html#smtpd_data_restrictions))
5656

5757
* `postfix_sasl_auth_enable` [default: `true`]: Enable SASL authentication in the SMTP client
58-
* `postfix_sasl_user` [default: `postmaster@{{ ansible_domain }}`]: SASL relay username
58+
* `postfix_sasl_user` [default: `postmaster@{{ ansible_facts['domain'] }}`]: SASL relay username
5959
* `postfix_sasl_password` [default: `k8+haga4@#pR`]: SASL relay password **Make sure to change!**
6060
* `postfix_sasl_security_options` [default: `noanonymous`]: SMTP client SASL security options
6161
* `postfix_sasl_tls_security_option` [default: `noanonymous`]: SMTP client SASL TLS security options

defaults/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ postfix_install:
77
- sasl2-bin
88
- libsasl2-modules
99

10-
postfix_hostname: "{{ ansible_fqdn }}"
11-
postfix_mailname: "{{ ansible_fqdn }}"
10+
postfix_hostname: "{{ ansible_facts['fqdn'] }}"
11+
postfix_mailname: "{{ ansible_facts['fqdn'] }}"
1212

1313
postfix_default_database_type: hash
1414
postfix_aliases: []
@@ -33,7 +33,7 @@ postfix_relayhost_port: 587
3333
postfix_relaytls: false
3434

3535
postfix_sasl_auth_enable: true
36-
postfix_sasl_user: "postmaster@{{ ansible_domain }}"
36+
postfix_sasl_user: "postmaster@{{ ansible_facts['domain'] }}"
3737
postfix_sasl_password: 'k8+haga4@#pR'
3838
postfix_sasl_security_options: noanonymous
3939
postfix_sasl_tls_security_options: noanonymous

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
block:
99
- name: facts | set | is_docker_guest
1010
ansible.builtin.set_fact:
11-
is_docker_guest: "{{ ansible_virtualization_role | default('host') == 'guest' and ansible_virtualization_type | default('none') == 'docker' }}"
11+
is_docker_guest: "{{ ansible_facts['virtualization_role'] | default('host') == 'guest' and ansible_facts['virtualization_type'] | default('none') == 'docker' }}"
1212

1313
- name: facts | set | postfix_relayhosts
1414
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)