mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Handle custom script options of hostnames and destination variable
This commit is contained in:
@@ -2053,18 +2053,35 @@ class ec2(PluginFileInjector):
|
|||||||
compose_dict.update(self._compat_compose_vars())
|
compose_dict.update(self._compat_compose_vars())
|
||||||
# plugin provides "aws_ec2", but not this which the script gave
|
# plugin provides "aws_ec2", but not this which the script gave
|
||||||
ret['groups'] = {'ec2': True}
|
ret['groups'] = {'ec2': True}
|
||||||
# public_ip as hostname is non-default plugin behavior, script behavior
|
if source_vars.get('hostname_variable') is not None:
|
||||||
ret['hostnames'] = [
|
hnames = []
|
||||||
'network-interface.addresses.association.public-ip',
|
for expr in source_vars.get('hostname_variable').split(','):
|
||||||
'dns-name',
|
if expr == 'public_dns_name':
|
||||||
'private-dns-name'
|
hnames.append('dns-name')
|
||||||
]
|
elif not expr.startswith('tag:') and '_' in expr:
|
||||||
|
hnames.append(expr.replace('_', '-'))
|
||||||
|
else:
|
||||||
|
hnames.append(expr)
|
||||||
|
ret['hostnames'] = hnames
|
||||||
|
else:
|
||||||
|
# public_ip as hostname is non-default plugin behavior, script behavior
|
||||||
|
ret['hostnames'] = [
|
||||||
|
'network-interface.addresses.association.public-ip',
|
||||||
|
'dns-name',
|
||||||
|
'private-dns-name'
|
||||||
|
]
|
||||||
# The script returned only running state by default, the plugin does not
|
# The script returned only running state by default, the plugin does not
|
||||||
# https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options
|
# https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options
|
||||||
# options: pending | running | shutting-down | terminated | stopping | stopped
|
# options: pending | running | shutting-down | terminated | stopping | stopped
|
||||||
inst_filters['instance-state-name'] = ['running']
|
inst_filters['instance-state-name'] = ['running']
|
||||||
# end compatibility content
|
# end compatibility content
|
||||||
|
|
||||||
|
if source_vars.get('destination_variable') or source_vars.get('vpc_destination_variable'):
|
||||||
|
for fd in ('destination_variable', 'vpc_destination_variable'):
|
||||||
|
if source_vars.get(fd):
|
||||||
|
compose_dict['ansible_host'] = source_vars.get(fd)
|
||||||
|
break
|
||||||
|
|
||||||
if compose_dict:
|
if compose_dict:
|
||||||
ret['compose'] = compose_dict
|
ret['compose'] = compose_dict
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
boto_profile: /tmp/my_boto_stuff
|
boto_profile: /tmp/my_boto_stuff
|
||||||
compose:
|
compose:
|
||||||
ansible_host: public_ip_address
|
ansible_host: public_dns_name
|
||||||
ec2_account_id: owner_id
|
ec2_account_id: owner_id
|
||||||
ec2_ami_launch_index: ami_launch_index | string
|
ec2_ami_launch_index: ami_launch_index | string
|
||||||
ec2_architecture: architecture
|
ec2_architecture: architecture
|
||||||
@@ -50,9 +50,7 @@ filters:
|
|||||||
groups:
|
groups:
|
||||||
ec2: true
|
ec2: true
|
||||||
hostnames:
|
hostnames:
|
||||||
- network-interface.addresses.association.public-ip
|
|
||||||
- dns-name
|
- dns-name
|
||||||
- private-dns-name
|
|
||||||
iam_role_arn: arn:aws:iam::123456789012:role/test-role
|
iam_role_arn: arn:aws:iam::123456789012:role/test-role
|
||||||
keyed_groups:
|
keyed_groups:
|
||||||
- key: placement.availability_zone
|
- key: placement.availability_zone
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ properties:
|
|||||||
- triggeredalarmstate
|
- triggeredalarmstate
|
||||||
- value
|
- value
|
||||||
property_name_format: lower_case
|
property_name_format: lower_case
|
||||||
strict: true
|
strict: false
|
||||||
with_nested_properties: true
|
with_nested_properties: true
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
base_source_var = value_of_var
|
base_source_var = value_of_var
|
||||||
boto_profile = /tmp/my_boto_stuff
|
boto_profile = /tmp/my_boto_stuff
|
||||||
iam_role_arn = arn:aws:iam::123456789012:role/test-role
|
iam_role_arn = arn:aws:iam::123456789012:role/test-role
|
||||||
|
hostname_variable = public_dns_name
|
||||||
|
destination_variable = public_dns_name
|
||||||
regions = us-east-2,ap-south-1
|
regions = us-east-2,ap-south-1
|
||||||
regions_exclude = us-gov-west-1,cn-north-1
|
regions_exclude = us-gov-west-1,cn-north-1
|
||||||
destination_variable = public_dns_name
|
|
||||||
vpc_destination_variable = ip_address
|
vpc_destination_variable = ip_address
|
||||||
route53 = False
|
route53 = False
|
||||||
all_instances = True
|
all_instances = True
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ TEST_SOURCE_FIELDS = {
|
|||||||
INI_TEST_VARS = {
|
INI_TEST_VARS = {
|
||||||
'ec2': {
|
'ec2': {
|
||||||
'boto_profile': '/tmp/my_boto_stuff',
|
'boto_profile': '/tmp/my_boto_stuff',
|
||||||
'iam_role_arn': 'arn:aws:iam::123456789012:role/test-role'
|
'iam_role_arn': 'arn:aws:iam::123456789012:role/test-role',
|
||||||
|
'hostname_variable': 'public_dns_name',
|
||||||
|
'destination_variable': 'public_dns_name'
|
||||||
},
|
},
|
||||||
'gce': {},
|
'gce': {},
|
||||||
'openstack': {
|
'openstack': {
|
||||||
|
|||||||
Reference in New Issue
Block a user