Skip to content

Commit

Permalink
fix conditional statements include jinja2 templating (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo authored Dec 3, 2023
1 parent f58d62b commit 9f2dfc5
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 109 deletions.
4 changes: 2 additions & 2 deletions tests/integration/targets/block_storage_info/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- name: verify test gather vultr block storage volume info in check mode
ansible.builtin.assert:
that:
- result.vultr_block_storage_info|selectattr('label','equalto','{{ vultr_block_storage_name }}') | list | count == 1
- result.vultr_block_storage_info|selectattr('label','equalto',vultr_block_storage_name) | list | count == 1

- name: test gather vultr block storage volume info
vultr.cloud.block_storage_info:
Expand All @@ -28,7 +28,7 @@
- name: verify test gather vultr block storage volume info
ansible.builtin.assert:
that:
- result.vultr_block_storage_info|selectattr('label','equalto','{{ vultr_block_storage_name }}') | list | count == 1
- result.vultr_block_storage_info|selectattr('label','equalto',vultr_block_storage_name) | list | count == 1

- name: Delete the block storage volume
vultr.cloud.block_storage:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/dns_domain_info/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- name: verify test gather vultr dns domain info in check mode
ansible.builtin.assert:
that:
- result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1
- result.vultr_dns_domain_info|selectattr('domain','equalto',dns_domain_name) | list | count == 1

- name: test gather vultr dns domain info
vultr.cloud.dns_domain_info:
Expand All @@ -24,4 +24,4 @@
- name: verify test gather vultr dns domain info
ansible.builtin.assert:
that:
- result.vultr_dns_domain_info|selectattr('domain','equalto','{{ dns_domain_name }}') | list | count == 1
- result.vultr_dns_domain_info|selectattr('domain','equalto',dns_domain_name) | list | count == 1
20 changes: 10 additions & 10 deletions tests/integration/targets/dns_record/tasks/create_record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.data }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.priority | default(-1) }}
- result.vultr_dns_record.data == item.data
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.ttl | default(300)
- result.vultr_dns_record.priority == item.priority | default(-1)

- name: test create a dns record idempotence
vultr.cloud.dns_record:
Expand All @@ -55,8 +55,8 @@
ansible.builtin.assert:
that:
- result is not changed
- result.vultr_dns_record.data == "{{ item.data }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.priority | default(-1) }}
- result.vultr_dns_record.data == item.data
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.ttl | default(300)
- result.vultr_dns_record.priority == item.priority | default(-1)
40 changes: 20 additions & 20 deletions tests/integration/targets/dns_record/tasks/remove_record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.update_priority | default(item.priority | default(-1)) }}
- result.vultr_dns_record.data == item.update_data | default(item.data)
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.update_ttl | default(300)
- result.vultr_dns_record.priority == item.update_priority | default(item.priority | default(-1))

- name: test remove second dns record in check mode
vultr.cloud.dns_record:
Expand All @@ -36,11 +36,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.data | default(item.data) }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.priority | default(-1) }}
- result.vultr_dns_record.data == item.data | default(item.data)
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.ttl | default(300)
- result.vultr_dns_record.priority == item.priority | default(-1)
when: item.multiple is defined and item.multiple == true

- name: test remove a dns record
Expand All @@ -56,11 +56,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.update_priority | default(item.priority | default(-1)) }}
- result.vultr_dns_record.data == item.update_data | default(item.data)
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.update_ttl | default(300)
- result.vultr_dns_record.priority == item.update_priority | default(item.priority | default(-1))

- name: test remove second dns record
vultr.cloud.dns_record:
Expand All @@ -76,11 +76,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.data }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.priority | default(-1) }}
- result.vultr_dns_record.data == item.data
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.ttl | default(300)
- result.vultr_dns_record.priority == item.priority | default(-1)
when: item.multiple is defined and item.multiple == true

- name: test remove a dns record idempotence
Expand Down
30 changes: 15 additions & 15 deletions tests/integration/targets/dns_record/tasks/update_record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.data }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.ttl == {{ item.ttl | default(300) }}
- result.vultr_dns_record.priority == {{ item.priority | default(-1) }}
- result.vultr_dns_record.data == item.data
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.ttl == item.ttl | default(300)
- result.vultr_dns_record.priority == item.priority | default(-1)
when: item.multiple is undefined or item.multiple == false
- name: verify test add another dns record in check mode
ansible.builtin.assert:
Expand All @@ -43,11 +43,11 @@
ansible.builtin.assert:
that:
- result is changed
- result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }}
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.priority == {{ item.update_priority | default(-1) }}
- result.vultr_dns_record.data == item.update_data | default(item.data)
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.ttl == item.update_ttl | default(300)
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.priority == item.update_priority | default(-1)

- name: test update or add another dns record idempotence
vultr.cloud.dns_record:
Expand All @@ -63,8 +63,8 @@
ansible.builtin.assert:
that:
- result is not changed
- result.vultr_dns_record.data == "{{ item.update_data | default(item.data) }}"
- result.vultr_dns_record.name == "{{ item.name | default("") }}"
- result.vultr_dns_record.ttl == {{ item.update_ttl | default(300) }}
- result.vultr_dns_record.type == "{{ item.record_type | default('A') }}"
- result.vultr_dns_record.priority == {{ item.update_priority | default(-1) }}
- result.vultr_dns_record.data == item.update_data | default(item.data)
- result.vultr_dns_record.name == item.name | default('')
- result.vultr_dns_record.ttl == item.update_ttl | default(300)
- result.vultr_dns_record.type == item.record_type | default('A')
- result.vultr_dns_record.priority == item.update_priority | default(-1)
4 changes: 2 additions & 2 deletions tests/integration/targets/firewall_group_info/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- name: verify test gather vultr firewall group info in check mode
ansible.builtin.assert:
that:
- result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1
- result.vultr_firewall_group_info|selectattr('description','equalto',firewall_group_name) | list | count == 1

- name: test gather vultr firewall group info
vultr.cloud.firewall_group_info:
Expand All @@ -26,7 +26,7 @@
- name: verify test gather vultr firewall group info
ansible.builtin.assert:
that:
- result.vultr_firewall_group_info|selectattr('description','equalto','{{ firewall_group_name }}') | list | count == 1
- result.vultr_firewall_group_info|selectattr('description','equalto',firewall_group_name) | list | count == 1

- name: Delete the firewall group
vultr.cloud.firewall_group:
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/targets/firewall_rule/tasks/rule_absent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}"
- result.vultr_firewall_rule.port == "{{ rule.port_assert | default(rule.port | default('')) }}"
- result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}"
- result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }}
- result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}"
- result.vultr_firewall_rule.protocol == rule.protocol | default('tcp')
- result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default(''))
- result.vultr_firewall_rule.subnet == rule.subnet | default('')
- result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0)
- result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4')

- name: test absent firewall rule
vultr.cloud.firewall_rule:
Expand All @@ -40,11 +40,11 @@
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}"
- result.vultr_firewall_rule.port == "{{ rule.port_assert | default(rule.port | default('')) }}"
- result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}"
- result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }}
- result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}"
- result.vultr_firewall_rule.protocol == rule.protocol | default('tcp')
- result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default(''))
- result.vultr_firewall_rule.subnet == rule.subnet | default('')
- result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0)
- result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4')

- name: test absent firewall rule idempotence
vultr.cloud.firewall_rule:
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/targets/firewall_rule/tasks/rule_present.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}"
- result.vultr_firewall_rule.port == "{{ rule.port_assert | default(rule.port | default('')) }}"
- result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}"
- result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }}
- result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}"
- result.vultr_firewall_rule.protocol == rule.protocol | default('tcp')
- result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default(''))
- result.vultr_firewall_rule.subnet == rule.subnet | default('')
- result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0)
- result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4')

- name: test create firewall rule idempotence
vultr.cloud.firewall_rule:
Expand All @@ -55,8 +55,8 @@
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "{{ rule.protocol | default('tcp') }}"
- result.vultr_firewall_rule.port == "{{ rule.port_assert | default(rule.port | default('')) }}"
- result.vultr_firewall_rule.subnet == "{{ rule.subnet | default('') }}"
- result.vultr_firewall_rule.subnet_size == {{ rule.subnet_size | default(0) }}
- result.vultr_firewall_rule.ip_type == "{{ rule.ip_type | default('v4') }}"
- result.vultr_firewall_rule.protocol == rule.protocol | default('tcp')
- result.vultr_firewall_rule.port == rule.port_assert | default(rule.port | default(''))
- result.vultr_firewall_rule.subnet == rule.subnet | default('')
- result.vultr_firewall_rule.subnet_size == rule.subnet_size | default(0)
- result.vultr_firewall_rule.ip_type == rule.ip_type | default('v4')
4 changes: 2 additions & 2 deletions tests/integration/targets/firewall_rule_info/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- name: verify test gather vultr firewall rule info in check mode
ansible.builtin.assert:
that:
- result.vultr_firewall_rule_info|selectattr('notes','equalto','{{ firewall_group_name }}') | list | count == 1
- result.vultr_firewall_rule_info|selectattr('notes','equalto',firewall_group_name) | list | count == 1

- name: test gather vultr firewall rule info
vultr.cloud.firewall_rule_info:
Expand All @@ -37,7 +37,7 @@
- name: verify test gather vultr firewall rule info
ansible.builtin.assert:
that:
- result.vultr_firewall_rule_info|selectattr('notes','equalto','{{ firewall_group_name }}') | list | count == 1
- result.vultr_firewall_rule_info|selectattr('notes','equalto',firewall_group_name) | list | count == 1

- name: Delete the firewall group
vultr.cloud.firewall_group:
Expand Down
Loading

0 comments on commit 9f2dfc5

Please sign in to comment.