Skip to content

Commit

Permalink
[manual backport stable-5] Pick up app_callback -> set_password rathe…
Browse files Browse the repository at this point in the history
…r than app_callback -> set_passwd (ansible-collections#1482)

[manual backport stable-5] Pick up app_callback -> set_password rather than app_callback -> set_passwd

Pick up app_callback -> set_password rather than app_callback -> set_passwd
SUMMARY
Closes: ansible-collections#1449
Pick up app_callback -> set_password rather than app_callback -> set_passwd
ISSUE TYPE
Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION
Reviewed-by: Mark Chappell
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell
Reviewed-by: Jill R
  • Loading branch information
alinabuzachis authored May 3, 2023
1 parent 4178e9a commit 2e5a81a
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 34 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1258-ec2_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- ec2_instance - changes to integration tests to fix failures
2 changes: 2 additions & 0 deletions changelogs/fragments/20230424-ec2_instance-app_callback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_instance - Pick up ``app_callback -> set_password`` rather than ``app_callback -> set_passwd`` (https://github.com/ansible-collections/amazon.aws/issues/1449).
10 changes: 5 additions & 5 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,11 @@ def build_userdata(params):
return {'UserData': to_native(params.get('user_data'))}
if params.get('aap_callback'):
userdata = tower_callback_script(
tower_address=params.get('aap_callback').get('tower_address'),
job_template_id=params.get('aap_callback').get('job_template_id'),
host_config_key=params.get('aap_callback').get('host_config_key'),
windows=params.get('aap_callback').get('windows'),
passwd=params.get('aap_callback').get('set_passwd'),
tower_address=params.get("aap_callback").get("tower_address"),
job_template_id=params.get("aap_callback").get("job_template_id"),
host_config_key=params.get("aap_callback").get("host_config_key"),
windows=params.get("aap_callback").get("windows"),
passwd=params.get("aap_callback").get("set_password"),
)
return {'UserData': userdata}
return {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_block_devices
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-block-devices'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_checkmode_tests
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-checkmode'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_cpu_options
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-cpu-options'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_default_vpc
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-default-vpc'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_ebs_optimized
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-ebs-optimized'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_external_resource_attach
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-external-attach'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_hibernation_options
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-hibernation-options'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_iam_instance_profile
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-profile'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_minimal
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-minimal'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_multiple
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-multiple'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_no_wait
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-no-wait'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_metadata_options
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-metadata'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_security_group
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-sg'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_state_config_updates
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-state-config-updates'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_tags_and_vpc_settings
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-tags-vpc'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_termination_protection
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-temination'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
# defaults file for ec2_instance
# defaults file for ec2_instance_uptime
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-uptime'
4 changes: 2 additions & 2 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@
# Anything under 15 will trigger SnapshotCreationPerVolumeRateExceeded,
# this should now be automatically handled, but pause a little anyway to
# avoid being aggressive
pause: 10
pause: 15
label: "Generate extra snapshots - {{ item }}"

- name: Pause to allow creation to finish
pause:
minutes: 2
minutes: 3

# check that snapshot_ids and max_results are mutually exclusive
- name: Check that max_results and snapshot_ids are mutually exclusive
Expand Down
15 changes: 10 additions & 5 deletions tests/integration/targets/setup_ec2_instance_env/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
# defaults file for ec2_instance
ec2_instance_owner: 'integration-run-{{ resource_prefix }}'
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-{{ inventory_hostname }}'

# defaults file for ec2_instance tests
ec2_instance_test_name: 'ec2_instance'

ec2_instance_owner: 'integration-run-{{ ec2_instance_test_name }}'
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-{{ ec2_instance_test_name }}'

vpc_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}'
vpc_seed: '{{ resource_prefix }}-{{ ec2_instance_test_name }}'

Expand All @@ -14,6 +14,11 @@ vpc_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.0.0/16'
subnet_a_az: '{{ ec2_availability_zone_names[0] }}'
subnet_a_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.32.0/24'
subnet_a_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.32.'
subnet_a_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-a'
subnet_b_az: '{{ ec2_availability_zone_names[1] }}'
subnet_b_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.33.0/24'
subnet_b_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.33.'
subnet_b_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-b'

security_group_name_1: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-1'
security_group_name_2: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-2'
26 changes: 21 additions & 5 deletions tests/integration/targets/setup_ec2_instance_env/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name: "{{ vpc_name }}"
cidr_block: "{{ vpc_cidr }}"
tags:
Name: Ansible ec2_instance Testing VPC
Name: "{{ vpc_name }}"
tenancy: default
register: testing_vpc
notify:
Expand All @@ -25,7 +25,7 @@
cidr: "{{ subnet_a_cidr }}"
az: "{{ subnet_a_az }}"
resource_tags:
Name: "{{ resource_prefix }}-subnet-a"
Name: "{{ subnet_a_name }}"
register: testing_subnet_a

- name: "Create secondary subnet in zone B"
Expand All @@ -35,13 +35,13 @@
cidr: "{{ subnet_b_cidr }}"
az: "{{ subnet_b_az }}"
resource_tags:
Name: "{{ resource_prefix }}-subnet-b"
Name: "{{ subnet_b_name }}"
register: testing_subnet_b

- name: "create a security group with the vpc"
ec2_group:
state: present
name: "{{ resource_prefix }}-sg"
name: "{{ security_group_name_1 }}"
description: a security group for ansible tests
vpc_id: "{{ testing_vpc.vpc.id }}"
rules:
Expand All @@ -57,7 +57,7 @@

- name: "create secondary security group with the vpc"
ec2_group:
name: "{{ resource_prefix }}-sg-2"
name: "{{ security_group_name_2 }}"
description: a secondary security group for ansible tests
vpc_id: "{{ testing_vpc.vpc.id }}"
rules:
Expand All @@ -70,3 +70,19 @@
to_port: 80
cidr_ip: 0.0.0.0/0
register: sg2

- name: Preserve defaults for other roles
set_fact:
# Ensure variables are available outside of this role
vpc_cidr: '{{ vpc_cidr }}'
vpc_name: '{{ vpc_name }}'
subnet_a_az: '{{ subnet_a_az }}'
subnet_a_cidr: '{{ subnet_a_cidr }}'
subnet_a_startswith: '{{ subnet_a_startswith }}'
subnet_a_name: '{{ subnet_a_name }}'
subnet_b_az: '{{ subnet_b_az }}'
subnet_b_cidr: '{{ subnet_b_cidr }}'
subnet_b_startswith: '{{ subnet_b_startswith }}'
subnet_b_name: '{{ subnet_b_name }}'
security_group_name_1: '{{ security_group_name_1 }}'
security_group_name_2: '{{ security_group_name_2 }}'

0 comments on commit 2e5a81a

Please sign in to comment.