summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorSloane Hertel <shertel@redhat.com>2017-10-25 03:18:56 +0200
committeransibot <ansibot@users.noreply.github.com>2017-10-25 03:18:56 +0200
commit1dd55acbc211d854a6cded0f813334325bac4038 (patch)
treee237c0fe7dad0bb9425eb050f716757e49be6390 /test/integration
parentadded .vscode to gitignore file (#32106) (diff)
downloadansible-1dd55acbc211d854a6cded0f813334325bac4038.tar.xz
ansible-1dd55acbc211d854a6cded0f813334325bac4038.zip
ec2_group: add rule description support - fixes #29040 (#30273)
* ec2_group: add support for rule descriptions. * Document rule description feature and add an example using it. * Fix removing rule descriptions. * Add integration tests to verify adding/modifying/removing rule descriptions works as expected. * Add permissions to hacking/aws_config/testing_policies/ec2-policy.json for updating ingress and egress rule descriptions. * ec2_group: add backwards compatibility with older versions of botocore for rule descriptions. * Add compatibility with older version of botocore for ec2_group integration tests. * ec2_group: move HAS_RULE_DESCRIPTION to be checked first. * Make requested change * Pass around a variable instead of client * Make sure has_rule_description defaults to None * Fail if rule_desc is in any ingress/egress rules and the the botocore version < 1.7.2 * Remove unnecessary variable * Fix indentation for changed=True when updating rule descriptions. * minor refactor to remove duplicate code * add missing parameter * Fix pep8 * Update test policy.
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/ec2_group/tasks/main.yml181
1 files changed, 181 insertions, 0 deletions
diff --git a/test/integration/targets/ec2_group/tasks/main.yml b/test/integration/targets/ec2_group/tasks/main.yml
index 231c35b1d1..1a94cba5a3 100644
--- a/test/integration/targets/ec2_group/tasks/main.yml
+++ b/test/integration/targets/ec2_group/tasks/main.yml
@@ -629,6 +629,187 @@
# ============================================================
+ - name: test adding a rule and egress rule descriptions (expected changed=true)
+ ec2_group:
+ name: '{{ec2_group_name}}'
+ description: '{{ec2_group_description}}'
+ ec2_region: '{{ec2_region}}'
+ ec2_access_key: '{{ec2_access_key}}'
+ ec2_secret_key: '{{ec2_secret_key}}'
+ security_token: '{{security_token}}'
+ vpc_id: '{{ vpc_result.vpc.id }}'
+ # purge the other rules so assertions work for the subsequent tests for rule descriptions
+ purge_rules_egress: true
+ purge_rules: true
+ state: present
+ rules:
+ - proto: "tcp"
+ ports:
+ - 8281
+ cidr_ipv6: 1001:d00::/24
+ rule_desc: ipv6 rule desc 1
+ rules_egress:
+ - proto: "tcp"
+ ports:
+ - 8282
+ cidr_ip: 2.2.2.2/32
+ rule_desc: egress rule desc 1
+ register: result
+
+ - name: assert that rule descriptions are created (expected changed=true)
+ # Only assert this if rule description is defined as the botocore version may < 1.7.2.
+ # It's still helpful to have these tests run on older versions since it verifies backwards
+ # compatibility with this feature.
+ assert:
+ that:
+ - 'result.changed'
+ - 'result.ip_permissions[0].ipv6_ranges[0].description == "ipv6 rule desc 1"'
+ - 'result.ip_permissions_egress[0].ip_ranges[0].description == "egress rule desc 1"'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is defined
+
+ - name: if an older version of botocore is installed changes should still have changed due to purged rules (expected changed=true)
+ assert:
+ that:
+ - 'result.changed'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is undefined
+
+ # ============================================================
+
+ - name: test modifying rule and egress rule descriptions (expected changed=true)
+ ec2_group:
+ name: '{{ec2_group_name}}'
+ description: '{{ec2_group_description}}'
+ ec2_region: '{{ec2_region}}'
+ ec2_access_key: '{{ec2_access_key}}'
+ ec2_secret_key: '{{ec2_secret_key}}'
+ security_token: '{{security_token}}'
+ vpc_id: '{{ vpc_result.vpc.id }}'
+ purge_rules_egress: false
+ purge_rules: false
+ state: present
+ rules:
+ - proto: "tcp"
+ ports:
+ - 8281
+ cidr_ipv6: 1001:d00::/24
+ rule_desc: ipv6 rule desc 2
+ rules_egress:
+ - proto: "tcp"
+ ports:
+ - 8282
+ cidr_ip: 2.2.2.2/32
+ rule_desc: egress rule desc 2
+ register: result
+
+ - name: assert that rule descriptions were modified (expected changed=true)
+ # Only assert this if rule description is defined as the botocore version may < 1.7.2.
+ # It's still helpful to have these tests run on older versions since it verifies backwards
+ # compatibility with this feature.
+ assert:
+ that:
+ - 'result.changed'
+ - 'result.ip_permissions[0].ipv6_ranges[0].description == "ipv6 rule desc 2"'
+ - 'result.ip_permissions_egress[0].ip_ranges[0].description == "egress rule desc 2"'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is defined
+
+ - name: if an older version of botocore is installed everything should stay the same (expected changed=false)
+ assert:
+ that:
+ - 'not result.changed'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is undefined
+
+ # ============================================================
+
+ - name: test that keeping the same rule descriptions (expected changed=false)
+ ec2_group:
+ name: '{{ec2_group_name}}'
+ description: '{{ec2_group_description}}'
+ ec2_region: '{{ec2_region}}'
+ ec2_access_key: '{{ec2_access_key}}'
+ ec2_secret_key: '{{ec2_secret_key}}'
+ security_token: '{{security_token}}'
+ vpc_id: '{{ vpc_result.vpc.id }}'
+ purge_rules_egress: false
+ purge_rules: false
+ state: present
+ rules:
+ - proto: "tcp"
+ ports:
+ - 8281
+ cidr_ipv6: 1001:d00::/24
+ rule_desc: ipv6 rule desc 2
+ rules_egress:
+ - proto: "tcp"
+ ports:
+ - 8282
+ cidr_ip: 2.2.2.2/32
+ rule_desc: egress rule desc 2
+ register: result
+
+ - name: assert that rule descriptions stayed the same (expected changed=false)
+ # Only assert this if rule description is defined as the botocore version may < 1.7.2.
+ # It's still helpful to have these tests run on older versions since it verifies backwards
+ # compatibility with this feature.
+ assert:
+ that:
+ - 'not result.changed'
+ - 'result.ip_permissions[0].ipv6_ranges[0].description == "ipv6 rule desc 2"'
+ - 'result.ip_permissions_egress[0].ip_ranges[0].description == "egress rule desc 2"'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is defined
+
+ - name: if an older version of botocore is installed everything should stay the same (expected changed=false)
+ assert:
+ that:
+ - 'not result.changed'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is undefined
+
+ # ============================================================
+
+ - name: test removing rule descriptions (expected changed=true)
+ ec2_group:
+ name: '{{ec2_group_name}}'
+ description: '{{ec2_group_description}}'
+ ec2_region: '{{ec2_region}}'
+ ec2_access_key: '{{ec2_access_key}}'
+ ec2_secret_key: '{{ec2_secret_key}}'
+ security_token: '{{security_token}}'
+ vpc_id: '{{ vpc_result.vpc.id }}'
+ purge_rules_egress: false
+ purge_rules: false
+ state: present
+ rules:
+ - proto: "tcp"
+ ports:
+ - 8281
+ cidr_ipv6: 1001:d00::/24
+ rule_desc:
+ rules_egress:
+ - proto: "tcp"
+ ports:
+ - 8282
+ cidr_ip: 2.2.2.2/32
+ rule_desc:
+ register: result
+
+ - name: assert that rule descriptions were removed (expected changed=true)
+ # Only assert this if rule description is defined as the botocore version may < 1.7.2.
+ # It's still helpful to have these tests run on older versions since it verifies backwards
+ # compatibility with this feature.
+ assert:
+ that:
+ - 'result.changed'
+ - 'not result.ip_permissions[0].ipv6_ranges[0].description'
+ - 'not result.ip_permissions_egress[0].ip_ranges[0].description'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is defined
+
+ - name: if an older version of botocore is installed everything should stay the same (expected changed=false)
+ assert:
+ that:
+ - 'not result.changed'
+ when: result.ip_permissions_egress[0].ip_ranges[0].description is undefined
+
+ # ============================================================
+
- name: test state=absent (expected changed=true)
ec2_group:
name: '{{ec2_group_name}}'