|
25 | 25 | required: True |
26 | 26 | choices: ['ovirt', 'ovirt.ovirt.ovirt', 'redhat.rhv.ovirt'] |
27 | 27 | ovirt_url: |
28 | | - description: URL to ovirt-engine API. |
| 28 | + description: URL to ovirt-engine API. You can also use templating to specify the value of the O(ovirt_url). |
29 | 29 | required: True |
30 | 30 | env: |
31 | 31 | - name: OVIRT_URL |
32 | 32 | ovirt_username: |
33 | | - description: ovirt authentication user. |
| 33 | + description: ovirt authentication user. You can also use templating to specify the value of the O(ovirt_username). |
34 | 34 | required: True |
35 | 35 | env: |
36 | 36 | - name: OVIRT_USERNAME |
37 | 37 | ovirt_password: |
38 | | - description: ovirt authentication password. |
| 38 | + description: ovirt authentication password. You can also use templating to specify the value of the O(ovirt_password). |
39 | 39 | required : True |
40 | 40 | env: |
41 | 41 | - name: OVIRT_PASSWORD |
|
80 | 80 | dev: "'dev' in tags" |
81 | 81 | compose: |
82 | 82 | ansible_host: devices["eth0"][0] |
| 83 | +
|
| 84 | +# Specify `ovirt_url`, `ovirt_username`, and `ovirt_password` using templating or as an encrypted vault string |
| 85 | +# proxmox.yml |
| 86 | +plugin: @NAMESPACE@.@[email protected] |
| 87 | +ovirt_url: "{{ lookup('ansible.builtin.ini', 'url', section='ovirt', file='file.ini') }}" |
| 88 | +ovirt_username: "{{ lookup('ansible.builtin.env', 'OVIRT_USERNAME') | default('ansible@internal') }}" |
| 89 | +ovirt_password: !vault | |
| 90 | + $ANSIBLE_VAULT;1.1;AES256 |
| 91 | + 62353634333163633336343265623632626339313032653563653165313262343931643431656138 |
| 92 | + 6134333736323265656466646539663134306166666237630a653363623262636663333762316136 |
| 93 | + 34616361326263383766366663393837626437316462313332663736623066656237386531663731 |
| 94 | + 3037646432383064630a663165303564623338666131353366373630656661333437393937343331 |
| 95 | + 32643131386134396336623736393634373936356332623632306561356361323737313663633633 |
| 96 | + 6231313333666361656537343562333337323030623732323833 |
83 | 97 | ''' |
84 | 98 |
|
85 | 99 | from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable |
@@ -237,6 +251,13 @@ def parse(self, inventory, loader, path, cache=True): |
237 | 251 |
|
238 | 252 | config = self._read_config_data(path) |
239 | 253 |
|
| 254 | + # Read and template auth options |
| 255 | + for auth_option_name in ('ovirt_url', 'ovirt_username', 'ovirt_password'): |
| 256 | + auth_option_value = self.get_option(auth_option_name) |
| 257 | + if self.templar.is_template(auth_option_value): |
| 258 | + auth_option_value = self.templar.template(auth_option_value, disable_lookups=False) |
| 259 | + self.set_option(auth_option_name, auth_option_value) |
| 260 | + |
240 | 261 | self.connection = sdk.Connection( |
241 | 262 | url=self.get_option('ovirt_url'), |
242 | 263 | username=self.get_option('ovirt_username'), |
|
0 commit comments