Re: [ansible-project] Re: Print only output after assessmentTemplateArn

2019-03-28 Thread tinkuchowdary32
thank you for the advise but i am new to json can you please help with the 
commad or any reference link

On Wednesday, March 27, 2019 at 11:01:52 PM UTC-7, Dick Visser wrote:
>
> The output of that command is already json. Instead of fragile filtering a 
> (hopefully) single line that contains your value and then trying to unquote 
> that, please use the entire output in combination with the from_json filter 
> to access the value. 
>
> Dick
>
> On Wed, 27 Mar 2019 at 23:59, > wrote:
>
>> playbook task
>>
>> - name: "create Assessment template" 
>>
>> command: "{{ item }}"
>>
>> with_items: 
>>
>>   - aws inspector create-assessment-template --assessment-target-arn 
>> {{ target_arn }} --assessment-template-name {{ assessment_template_name }} 
>> --duration-in-seconds {{ run_duration }} --rules-package-arns {{ rules_arn 
>> }}
>>
>> register: template_arn
>>
>> tags: create-assessment-template
>>
>>   - debug:
>>
>>   var: template_arn.results.0.stdout_lines[1]
>>
>> tags: create-assessment-template
>>
>> On Wednesday, March 27, 2019 at 3:57:05 PM UTC-7, tinkuch...@gmail.com 
>> wrote:
>>>
>>> how can i get only the arn value but not complete output saved in to 
>>> variable
>>>
>>> in the below example
>>>
>>> TASK [debug] 
>>> 
>>>
>>> ok: [localhost] => {
>>>
>>> "template_arn.results.0.stdout_lines[1]": "  
>>>   \"assessmentTemplateArn\": 
>>> \"arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\""
>>>
>>>
>>>
>>> i want to print 
>>> only 
>>> arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\
>>>  
>>> i dont want assessmentTemplateArn to be saved to my variable 
>>> Can anyone please help
>>>
>>> Thank you 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/b73f4838-849d-4590-9231-2007e0acd344%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0efad1e6-ce2c-4f8e-9f31-4d753c35f2c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Print only output after assessmentTemplateArn

2019-03-27 Thread tinkuchowdary32
playbook task

- name: "create Assessment template" 

command: "{{ item }}"

with_items: 

  - aws inspector create-assessment-template --assessment-target-arn {{ 
target_arn }} --assessment-template-name {{ assessment_template_name }} 
--duration-in-seconds {{ run_duration }} --rules-package-arns {{ rules_arn 
}}

register: template_arn

tags: create-assessment-template

  - debug:

  var: template_arn.results.0.stdout_lines[1]

tags: create-assessment-template

On Wednesday, March 27, 2019 at 3:57:05 PM UTC-7, tinkuch...@gmail.com 
wrote:
>
> how can i get only the arn value but not complete output saved in to 
> variable
>
> in the below example
>
> TASK [debug] 
> 
>
> ok: [localhost] => {
>
> "template_arn.results.0.stdout_lines[1]": "  
>   \"assessmentTemplateArn\": 
> \"arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\""
>
>
>
> i want to print 
> only 
> arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\
>  
> i dont want assessmentTemplateArn to be saved to my variable 
> Can anyone please help
>
> Thank you 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b73f4838-849d-4590-9231-2007e0acd344%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Print only output after assessmentTemplateArn

2019-03-27 Thread tinkuchowdary32
how can i get only the arn value but not complete output saved in to 
variable

in the below example

TASK [debug] 


ok: [localhost] => {

"template_arn.results.0.stdout_lines[1]": "  
  \"assessmentTemplateArn\": 
\"arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\""



i want to print 
only 
arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\
 
i dont want assessmentTemplateArn to be saved to my variable 
Can anyone please help

Thank you 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/30bc7d22-2879-4045-88b0-adcf4cc75852%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Need help with how to grab public ip and use it for later part in playbook

2019-03-26 Thread tinkuchowdary32
Hello Sebastian

Thank you for the help i was able to get it working 

i have another problem how can i get only the arn value but not complete 
output saved in to variable

in the below example

TASK [debug] 


ok: [localhost] => {

"template_arn.results.0.stdout_lines[1]": "\"assessmentTemplateArn\": 
\"arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\""



i want to print 
only 
arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\
 
i dont want assessmentTemplateArn to be saved to my variable 
Can anyone please help

Thank you 

On Thursday, March 21, 2019 at 2:48:03 PM UTC-7, tinkuch...@gmail.com wrote:
>
> here is the dubug output ec2-facts
>
> "ec2": {
> "changed": false, 
> "failed": false, 
> "instances": [
> {
> "ami_launch_index": 0, 
> "architecture": "x86_64", 
> "block_device_mappings": [
> {
> "device_name": "/dev/xvda", 
> "ebs": {
> "attach_time": "2019-03-21T18:28:03+00:00", 
> "delete_on_termination": true, 
> "status": "attached", 
> "volume_id": "vol-"
> }
> }
> ], 
> "client_token": "", 
> "cpu_options": {
> "core_count": 1, 
> "threads_per_core": 1
> }, 
> "ebs_optimized": false, 
> "ena_support": true, 
> "hibernation_options": {
> "configured": false
> }, 
> "hypervisor": "xen", 
> "image_id": "ami-", 
> "instance_id": "i-xxx", 
> "instance_type": "t2.micro", 
> "key_name": "x", 
> "launch_time": "2019-03-21T18:28:03+00:00", 
> "monitoring": {
> "state": "disabled"
> }, 
> "network_interfaces": [
> {
> "association": {
> "ip_owner_id": "amazon", 
> "public_dns_name": "
> ec2-x.us-east-2.compute.amazonaws.com", 
> "public_ip": "xx.xx.xx.51"
> }, 
> "attachment": {
> "attach_time": "2019-03-21T18:28:03+00:00", 
> "attachment_id": "eni-attach-xx", 
> "delete_on_termination": true, 
> "device_index": 0, 
> "status": "attached"
> }, 
> "description": "", 
> "groups": [
> {
> "group_id": "sg-xx", 
> "group_name": "xx"
> }
> ], 
> "ipv6_addresses": [], 
> "mac_address": "xx:66:xx:77:d4:f4", 
> "network_interface_id": "eni-xxx", 
> "owner_id": "xx", 
> "private_dns_name": 
> "ip-xxx8.us-east-2.compute.internal", 
> "private_ip_address": "1xx", 
> "private_ip_addresses": [
> {
> "association": {
> "ip_owner_id": "amazon", 
> "public_dns_name": "
> ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com", 
> "public_ip": "18.x.xx.xx
> }, 
> "primary": true, 
> "private_dns_name": 
> "xx.us-east-2.compute.internal", 
> "private_ip_address": "xx"
> }
> ], 
> "source_dest_check": true, 
> "status": "in-use", 
> "subnet_id": "subnet-", 
> "vpc_id": "vpc-x"
> }
> ], 
> "placement": {
> "availability_zone": "us-east-2c", 
> "group_name": "", 
> "tenancy": "default"
> }, 
> "private_dns_name": "xxx.us-east-2.compute.internal", 
>

[ansible-project] Re: Need help with how to grab public ip and use it for later part in playbook

2019-03-21 Thread tinkuchowdary32
Thank you sebastian for quick reply 
unfortunately that didn't work

here the part that i am running

  - name: "gather instance facts"
ec2_instance_facts:
  instance_ids: i-xx
  region: "{{ region }}"
delegate_to: localhost
when: ec2_instance_prov == 'no'
register: ec2
tags:
  - gather-facts
  - provision-ec2
  - debug: 
  var: ec2.instances.0.public_ip_address 
tags:
  - gather-facts

after i run this i see no output

PLAY [Provision an EC2 Instance] 
*

TASK [gather instance facts] 
*
ok: [localhost -> localhost]

TASK [debug] 
*
ok: [localhost] => {
"ec2.instances.0.public_ip_address": "VARIABLE IS NOT DEFINED!"
}

PLAY RECAP 
***
localhost  : ok=2changed=0unreachable=0
failed=0   


On Thursday, March 21, 2019 at 2:48:03 PM UTC-7, tinkuch...@gmail.com wrote:
>
> here is the dubug output ec2-facts
>
> "ec2": {
> "changed": false, 
> "failed": false, 
> "instances": [
> {
> "ami_launch_index": 0, 
> "architecture": "x86_64", 
> "block_device_mappings": [
> {
> "device_name": "/dev/xvda", 
> "ebs": {
> "attach_time": "2019-03-21T18:28:03+00:00", 
> "delete_on_termination": true, 
> "status": "attached", 
> "volume_id": "vol-"
> }
> }
> ], 
> "client_token": "", 
> "cpu_options": {
> "core_count": 1, 
> "threads_per_core": 1
> }, 
> "ebs_optimized": false, 
> "ena_support": true, 
> "hibernation_options": {
> "configured": false
> }, 
> "hypervisor": "xen", 
> "image_id": "ami-", 
> "instance_id": "i-xxx", 
> "instance_type": "t2.micro", 
> "key_name": "x", 
> "launch_time": "2019-03-21T18:28:03+00:00", 
> "monitoring": {
> "state": "disabled"
> }, 
> "network_interfaces": [
> {
> "association": {
> "ip_owner_id": "amazon", 
> "public_dns_name": "
> ec2-x.us-east-2.compute.amazonaws.com", 
> "public_ip": "xx.xx.xx.51"
> }, 
> "attachment": {
> "attach_time": "2019-03-21T18:28:03+00:00", 
> "attachment_id": "eni-attach-xx", 
> "delete_on_termination": true, 
> "device_index": 0, 
> "status": "attached"
> }, 
> "description": "", 
> "groups": [
> {
> "group_id": "sg-xx", 
> "group_name": "xx"
> }
> ], 
> "ipv6_addresses": [], 
> "mac_address": "xx:66:xx:77:d4:f4", 
> "network_interface_id": "eni-xxx", 
> "owner_id": "xx", 
> "private_dns_name": 
> "ip-xxx8.us-east-2.compute.internal", 
> "private_ip_address": "1xx", 
> "private_ip_addresses": [
> {
> "association": {
> "ip_owner_id": "amazon", 
> "public_dns_name": "
> ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com", 
> "public_ip": "18.x.xx.xx
> }, 
>

[ansible-project] Need help with how to grab public ip and use it for later part in playbook

2019-03-21 Thread tinkuchowdary32
here is the dubug output ec2-facts

"ec2": {
"changed": false, 
"failed": false, 
"instances": [
{
"ami_launch_index": 0, 
"architecture": "x86_64", 
"block_device_mappings": [
{
"device_name": "/dev/xvda", 
"ebs": {
"attach_time": "2019-03-21T18:28:03+00:00", 
"delete_on_termination": true, 
"status": "attached", 
"volume_id": "vol-"
}
}
], 
"client_token": "", 
"cpu_options": {
"core_count": 1, 
"threads_per_core": 1
}, 
"ebs_optimized": false, 
"ena_support": true, 
"hibernation_options": {
"configured": false
}, 
"hypervisor": "xen", 
"image_id": "ami-", 
"instance_id": "i-xxx", 
"instance_type": "t2.micro", 
"key_name": "x", 
"launch_time": "2019-03-21T18:28:03+00:00", 
"monitoring": {
"state": "disabled"
}, 
"network_interfaces": [
{
"association": {
"ip_owner_id": "amazon", 
"public_dns_name": 
"ec2-x.us-east-2.compute.amazonaws.com", 
"public_ip": "xx.xx.xx.51"
}, 
"attachment": {
"attach_time": "2019-03-21T18:28:03+00:00", 
"attachment_id": "eni-attach-xx", 
"delete_on_termination": true, 
"device_index": 0, 
"status": "attached"
}, 
"description": "", 
"groups": [
{
"group_id": "sg-xx", 
"group_name": "xx"
}
], 
"ipv6_addresses": [], 
"mac_address": "xx:66:xx:77:d4:f4", 
"network_interface_id": "eni-xxx", 
"owner_id": "xx", 
"private_dns_name": 
"ip-xxx8.us-east-2.compute.internal", 
"private_ip_address": "1xx", 
"private_ip_addresses": [
{
"association": {
"ip_owner_id": "amazon", 
"public_dns_name": 
"ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com", 
"public_ip": "18.x.xx.xx
}, 
"primary": true, 
"private_dns_name": 
"xx.us-east-2.compute.internal", 
"private_ip_address": "xx"
}
], 
"source_dest_check": true, 
"status": "in-use", 
"subnet_id": "subnet-", 
"vpc_id": "vpc-x"
}
], 
"placement": {
"availability_zone": "us-east-2c", 
"group_name": "", 
"tenancy": "default"
}, 
"private_dns_name": "xxx.us-east-2.compute.internal", 
"private_ip_address": "xxx.xx.xx.xx", 
"product_codes": [], 
"public_dns_name": 
"xxx.us-east-2.compute.amazonaws.com", 
"public_ip_address": "xx.xxx.44.51", 
"root_device_name": "/dev/xvda", 
"root_device_type": "ebs", 
"security_groups": [
{
"group_id": "sg-", 
"group_name": "xx"
}
], 
"source_dest_check": true, 
"state": {
"code": 64, 
"name": "stopping"
}, 
"state_reason": {
"code": "Client.UserInitiatedShutdown", 
"message": "Client.UserInitiatedShutdown: User 
initiated shutdown"
}, 
"state_transition_reason": "User initiated (2019-03-21 
19:33:16 GMT)", 
"subnet_id": "subnet-xxx", 
"virtualization_type": "hvm", 
"vpc_id": "vpc-"
}