[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", 
>

Re: [ansible-project] Launch instances from a file

2019-03-26 Thread Sudheer Satyanarayana


On 26/03/19 11:16 PM, shyam.r...@gmail.com wrote:


Hi Sudheer,
Thanks for your update. I want to read the file line by line. is
it possible to do through Ansible ?
I have tried with Lookup plugin and Im able to save the instance
name, HTTP port number and Portnumber in a separate vaiable from
CSV file.


So, you are already reading the file and fetching the details you want?


Here my requirement is to iterate the CSV file contents line by
line and need to launch the instances from the CSV file.


If you have a CSV file, us the read_csv module.

https://docs.ansible.com/ansible/devel/modules/read_csv_module.html


--

Sudheer Satyanarayana
System Administrator And Developer
Tech Chorus - https://www.techchorus.net

--
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/04a3890b-1186-3c69-9d82-cf688be7decd%40techchorus.net.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Files validation

2019-03-26 Thread Dick Visser
What does your playbook look like?
Also how is this mysterious run time creation of vars files setup?

Dick

On Tue, 26 Mar 2019 at 18:06, Karthik Sivakumar 
wrote:

> Hi
>
> While executing the main.yml file , the ansible controller validate the
> main.yml , it checks for all files in the path , if the files is present ,
> it runs sucessfully.
> Eventhough we are creating the file at run time our ansible playbook
> checks whether the file is present or not.
> How to overcome this problem. We don't want to hardcode the file name in
> the playbook.
> We are using var_files in ansible playbook section to create a file at run
> time.
>
> could you please check on this issue
>
> Thanks & Regards,
> Karthik
>
>
>
>
> --
> 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/70aacfad-c5a7-4585-a01f-b0511d53cf93%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/CAL8fbwPLrgMLNfHRYdpHpiiLce%3Dh5p4f8zBeHEZDEE7qV0-sAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: aws_ec2 & constructed not working as per documentation?

2019-03-26 Thread Derek Murawsky
So after rereading the constructed documentation, and fiddling around, I 
managed to get this working. 

RE: constructed Documentation 
:
 
"Only variables already available from previous inventories or the fact 
cache can be used for templating." wasn't quite clear. I assumed that 
variables and groups created within constructed would be available within 
constructed and that is not the case. By creating the source groups in the 
aws_ec2.yml file, I was then able to create my dynamic logical groups in 
1-groups.config. The results are below. 

aws_ec2.yml
plugin: aws_ec2
regions:
 - us-west-2

boto_profile: correct_profile
keyed_groups:
 - prefix: tag
   key: tags
 - prefix: instance_type
   key: instance_type
 - key: 'security_groups|json_query("[].group_name")'
   prefix: "security_group"
 - key: placement.region
   prefix: aws_region
 - key: platform
   prefix: platform

hostnames:
 - private-ip-address


1-groups.config
plugin: constructed
groups:
 managed_web_servers: 
(group_names|intersect(['platform_windows','tag_creator_deployagent_service','tag_Name*web_server']))




On Tuesday, March 26, 2019 at 2:40:26 PM UTC-4, Derek Murawsky wrote:
>
> Hi All,
>
> I'm trying to create a dynamic group of hosts that are in the intersection 
> of 3 other groups. From what I am reading, I see that the new aws_ec2 and 
> constructed inventory plugins should be able to do what I want. However I 
> try per the documentation and it doesn't appear to be working. 
>
> I have the following:
>
>  aws_ec2.yml
> plugin: aws_ec2
> regions:
>  - us-west-2
>
> boto_profile: correct_profile
> hostnames:
>  - private-ip-address
>
>
> 1-groups.config
> plugin: constructed
> keyed_groups:
>  - prefix: tag
>key: tags
>  - prefix: instance_type
>key: instance_type
>  - key: 'security_groups|json_query("[].group_name")'
>prefix: "security_group"
>  - key: placement.region
>prefix: aws_region
>  - key: platform
>prefix: platform
> groups:
>  managed_web_servers: 
> (group_names|intersect(['platform_windows','tag_creator_deployagent_service']))
>  # complex group membership
>  multi_group: (group_names)
>
>
> I run it with 
> ansible-inventory -i inventory/path/aws_ec2.yml  -i inventory/1-groups.
> config
>
> In my output, I do see the platform_windows and 
> tag_creator_deployagent_service groups. I do see multi_group as well. 
> However managed_web_servers are nowhere to be found. I thought I pulled 
> this from the documentation correctly, but it's not doing what I suspect it 
> should. Could anyone share advice on this and/or help me debug it? There 
> don't seem to be a lot of examples of the new inventory plugins, or my 
> google-fu is failing me. 
>
> Thanks,
> -Derek
>

-- 
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/16280d92-e659-4711-8687-fecc90e6c5b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] aws_ec2 & constructed not working as per documentation?

2019-03-26 Thread Derek Murawsky
Hi All,

I'm trying to create a dynamic group of hosts that are in the intersection 
of 3 other groups. From what I am reading, I see that the new aws_ec2 and 
constructed inventory plugins should be able to do what I want. However I 
try per the documentation and it doesn't appear to be working. 

I have the following:

 aws_ec2.yml
plugin: aws_ec2
regions:
 - us-west-2

boto_profile: correct_profile
hostnames:
 - private-ip-address


1-groups.config
plugin: constructed
keyed_groups:
 - prefix: tag
   key: tags
 - prefix: instance_type
   key: instance_type
 - key: 'security_groups|json_query("[].group_name")'
   prefix: "security_group"
 - key: placement.region
   prefix: aws_region
 - key: platform
   prefix: platform
groups:
 managed_web_servers: 
(group_names|intersect(['platform_windows','tag_creator_deployagent_service']))
 # complex group membership
 multi_group: (group_names)


I run it with 
ansible-inventory -i inventory/path/aws_ec2.yml  -i inventory/1-groups.
config

In my output, I do see the platform_windows and 
tag_creator_deployagent_service groups. I do see multi_group as well. 
However managed_web_servers are nowhere to be found. I thought I pulled 
this from the documentation correctly, but it's not doing what I suspect it 
should. Could anyone share advice on this and/or help me debug it? There 
don't seem to be a lot of examples of the new inventory plugins, or my 
google-fu is failing me. 

Thanks,
-Derek

-- 
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/7a131fa5-5159-488d-b348-93339dbae992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Launch instances from a file

2019-03-26 Thread shyam . rpms

>
> Hi Sudheer,
>
> Thanks for your update. I want to read the file line by line. is it possible 
> to do through Ansible ?
>
> I have tried with Lookup plugin and Im able to save the instance name, HTTP 
> port number and Portnumber in a separate vaiable from CSV file.
>
> Here my requirement is to iterate the CSV file contents line by line and need 
> to launch the instances from the CSV file.
>
> Any suggestions please.
>
>
Thank you,
Shyam 

-- 
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/67227a21-d10f-4ac4-a30d-52b80028da3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Files validation

2019-03-26 Thread Karthik Sivakumar
Hi 

While executing the main.yml file , the ansible controller validate the 
main.yml , it checks for all files in the path , if the files is present , 
it runs sucessfully.
Eventhough we are creating the file at run time our ansible playbook checks 
whether the file is present or not.
How to overcome this problem. We don't want to hardcode the file name in 
the playbook.
We are using var_files in ansible playbook section to create a file at run 
time.   

could you please check on this issue 

Thanks & Regards,
Karthik

 


-- 
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/70aacfad-c5a7-4585-a01f-b0511d53cf93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] debug statement not working

2019-03-26 Thread Sebastian Meyer
Hi Jerry,

On 25.03.19 18:12, Jerry Seven wrote:
> ok: [hostname] => {
> "msg": [

^ the [ tells you this is an array. This happens because you call
register on a task with a loop. For each item of the loop, a new dict
gets added to this array.

> {
> "_ansible_ignore_errors": null,
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": true,
> "cmd": "rpm -q TaniumClient",
> "delta": "0:00:00.024756",
> "end": "2019-03-25 13:10:34.751439",
> "failed": false,
> "invocation": {
> "module_args": {
> "_raw_params": "rpm -q TaniumClient",
> "_uses_shell": true,
> "chdir": null,
> "creates": null,
> "executable": null,
> "removes": null,
> "stdin": null,
> "warn": true
> }
> },
> "item": "TaniumClient",
> "rc": 0,
> "start": "2019-03-25 13:10:34.726683",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "TaniumClient-6.0.314.1442-1.rhe7.x86_64",
> "stdout_lines": [
> "TaniumClient-6.0.314.1442-1.rhe7.x86_64"
> ]
> },
> 
> 
> but
> 
> - debug:
> msg: "{{ pkg.results.stdout }}"
> 
> fails.  Seems like I should be able to print that.

You could print {{ pkg.results.0.stdout }} for the first element of the
loop, or {{ pkg.results.1.stdout }} for the second element of the loop.


> I just dont understand why it works:
>
> - debug:
>   msg: "{{ echo.results|map(attribute='stdout_lines')|list
> }}"

What this does is, take the array of dictionaries, and look in each
dictionary for the key stdout_lines. Then take the value of that key and
make a list out of it.

HTH
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/bf837057-c1bc-ce1f-0b8e-a2e24c94044b%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible and SQL Server ?

2019-03-26 Thread ryad9200000
Hi andres,

Okey !! Thank you very much for your answer !!

I will try this isue quickly !! ;)

Thanks,

Regards

Le mardi 26 mars 2019 14:09:42 UTC+1, lalo andres a écrit :
>
> im used win_command whit SQLCMD
>
> Ejm:
> - name: Copia Script DBA
>   win_copy:
> src: script_dbaGenerico.sql
> dest: "{{ servers_setup_dir }}\\script_dbaGenerico.sql"
>
> - name: exec createDBA
>   win_command: "sqlcmd -U sa -P {{ mssql_sa_pwd }} -S {{ ansible_hostname 
> }} -i script_dbaGenerico.sql"
>   args:
> chdir: "{{ servers_setup_dir }}"
>
> - name: Borra archivos instaladores
>   win_file:
> path: "{{ item }}"
> state: absent
>   with_items:
> - "{{ servers_setup_dir }}\\ConfigurationFile.ini"
> - "{{ servers_setup_dir }}\\script_dbaGenerico.sql"
>
> El mar., 26 mar. 2019 a las 10:00, > 
> escribió:
>
>> Hi all,
>>
>> I want know if Ansible can execut commands SQL for Microsoft SQL Server ?
>>
>> I think that possible with command powershell but what is syntax ansible ?
>>
>> for exemple, i want create table on my SQL Server (CREATE DATABASE 
>> ma_base)  with Ansible...
>>
>> What is a procedure ? I know there is win_shell and then ... ?
>>
>> Thank you very much community ansible !!
>>
>> Regards,
>>
>> -- 
>> 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-proje...@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/230bc455-d5db-457f-a92d-2ab99b2f1623%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Eduardo González R.
> Ingeniero Civil en Informatica
> Universidad del Biobio
>

-- 
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/cdd2a3db-dd11-487e-8513-1b7e86e22b86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible and SQL Server ?

2019-03-26 Thread lalo andres
im used win_command whit SQLCMD

Ejm:
- name: Copia Script DBA
  win_copy:
src: script_dbaGenerico.sql
dest: "{{ servers_setup_dir }}\\script_dbaGenerico.sql"

- name: exec createDBA
  win_command: "sqlcmd -U sa -P {{ mssql_sa_pwd }} -S {{ ansible_hostname
}} -i script_dbaGenerico.sql"
  args:
chdir: "{{ servers_setup_dir }}"

- name: Borra archivos instaladores
  win_file:
path: "{{ item }}"
state: absent
  with_items:
- "{{ servers_setup_dir }}\\ConfigurationFile.ini"
- "{{ servers_setup_dir }}\\script_dbaGenerico.sql"

El mar., 26 mar. 2019 a las 10:00,  escribió:

> Hi all,
>
> I want know if Ansible can execut commands SQL for Microsoft SQL Server ?
>
> I think that possible with command powershell but what is syntax ansible ?
>
> for exemple, i want create table on my SQL Server (CREATE DATABASE ma_base)
> with Ansible...
>
> What is a procedure ? I know there is win_shell and then ... ?
>
> Thank you very much community ansible !!
>
> Regards,
>
> --
> 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/230bc455-d5db-457f-a92d-2ab99b2f1623%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Eduardo González R.
Ingeniero Civil en Informatica
Universidad del Biobio

-- 
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/CAJuzu6SAQbBiMDc9SdF1sTzV81ZUY0L1PH8gQ3cj9Hy%3DzfChVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible and SQL Server ?

2019-03-26 Thread ryad9200000
Hi all,

I want know if Ansible can execut commands SQL for Microsoft SQL Server ?

I think that possible with command powershell but what is syntax ansible ?

for exemple, i want create table on my SQL Server (CREATE DATABASE ma_base)  
with Ansible...

What is a procedure ? I know there is win_shell and then ... ?

Thank you very much community ansible !!

Regards,

-- 
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/230bc455-d5db-457f-a92d-2ab99b2f1623%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-26 Thread Sebastian Meyer
On 26.03.19 13:01, 'Uffi Schnuffi' via Ansible Project wrote:
> This is no longer working with the new `import_playbook` module.
> 
> Is there a recommended way to achieve this (i.e. limiting hosts for an 
> imported playbook?). I have not found a way as of yet.

---
- import_playbook: test.yaml
  vars:
myhosts: plonk

---
- name: Test playbook
  hosts: all:&{{ myhosts }}
  tasks:
 - name: test var
   debug:
   msg: "GOOO"


works for me.

See:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.7.html#include-tasks-import-tasks-inline-variables

Sebastian


> 
> 
> On Friday, February 1, 2013 at 5:06:49 PM UTC+1, Lorin Hochstein wrote:
>>
>>
>> On Fri, Feb 1, 2013 at 11:02 AM, Daniel Hokka Zakrisson > > wrote:
>>
>>> Lorin Hochstein wrote:
 That approach works for limiting hosts when calling from the 
>>> command-line,
 but I'd like to do it from inside of a playbook. One of the motivations 
>>> is
 what Michael suggests in that original posting:

 "The same as the above example could be used with --limit stage or 
>>> --limit
 production to control inventory.   I really don't recommend this though,
 because leaving off limit would be pretty dangerous."

 If I want to limit execution of a playbook to staging servers, I worry
 about somebody forgetting the "--limit" flag. I'd prefer to do have a
 separate playbook, say "update-staging.yaml", that looks like this:

 - include: update.yaml hosts=staging

 Unfortunately, that doesn't work. Right now I'm using a makefile to 
>>> invoke
 my ansible playbooks to achieve this functionality, but I find that
 un-ansible-ish.

 Michael, would you accept merges that implemented this sort of host
 filtering on include statements? Would work the same as --limit on the
 command-line except it would be an argument to include.
>>>
>>> hosts: is already templateable with include arguments, so you could do
>>> hosts: webservers:&$hosts
>>> I think this will also lead to an error if you don't specify hosts, 
>>> instead
>>> of running against all of it.
>>>
>>>
>> Cool, that works. For anybody who hits this via google, here's a complete 
>> example:
>>
>> ping.yaml:
>>
>> - hosts: webservers:&$hosts
>>   tasks:
>>- name: ping the hosts
>>  action: ping
>>
>> pong.yaml:
>>
>> # Just ping the staging server
>> - include: ping.yaml hosts=staging
>>
>>
>>
>> This is a useful pattern, where's a good place to document this? 
>>
>> Lorin
>>
>>
>>  
>>
>>> Daniel
>>>
  Not sure what to call it (limit, limit-hosts, hosts)?


 Lorin


 On Fri, Feb 1, 2013 at 12:55 AM, Yeukhon Wong >> >
 wrote:

> I think you can try this
>
>
>>> https://groups.google.com/forum/#!msg/ansible-project/qfoeqytbRE4/SI58rlzeEwMJ
>
> If you ever need some exception (all in this group except XX) you can
> use
> hosts: group1:!except_this_group
>
>
> On Thursday, January 31, 2013 11:26:22 PM UTC-5, Lorin Hochstein wrote:
>>
>> When including a playbook in another playbook, is there any way to
>> limit
>> the hosts in the child playbook?
>>
>> For example, if I had an existing playbook (e.g.,
>> "configure-widget.yaml") that had its hosts set to "webservers", and I
>> wanted to write a playbook that only applied to the staging web 
>>> server,
>> is
>> there any way to do something like:
>>
>> - include: configure-widget.yaml limit-hosts=staging
>>
>>
>> Lorin
>>
>  --
> 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-proje...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



 --
 Lorin Hochstein
 Lead Architect - Cloud Services
 Nimbis Services, Inc.
 www.nimbisservices.com

 --
 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-proje...@googlegroups.com .
 For more options, visit https://groups.google.com/groups/opt_out.



>>>
>>> --
>>> 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-proje...@googlegroups.com .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>> -- 
>> Lorin Hochstein
>> Lead Architect - Cloud Services
>> Nimbis Services, Inc.
>> www.nimbisservices.com
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Tel.: +49-172-2057471
Mail: me...@b1-systems.de

B1 Systems GmbH
Os

Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-26 Thread 'Uffi Schnuffi' via Ansible Project
This is no longer working with the new `import_playbook` module.

Is there a recommended way to achieve this (i.e. limiting hosts for an 
imported playbook?). I have not found a way as of yet.


On Friday, February 1, 2013 at 5:06:49 PM UTC+1, Lorin Hochstein wrote:
>
>
> On Fri, Feb 1, 2013 at 11:02 AM, Daniel Hokka Zakrisson  > wrote:
>
>> Lorin Hochstein wrote:
>> > That approach works for limiting hosts when calling from the 
>> command-line,
>> > but I'd like to do it from inside of a playbook. One of the motivations 
>> is
>> > what Michael suggests in that original posting:
>> >
>> > "The same as the above example could be used with --limit stage or 
>> --limit
>> > production to control inventory.   I really don't recommend this though,
>> > because leaving off limit would be pretty dangerous."
>> >
>> > If I want to limit execution of a playbook to staging servers, I worry
>> > about somebody forgetting the "--limit" flag. I'd prefer to do have a
>> > separate playbook, say "update-staging.yaml", that looks like this:
>> >
>> > - include: update.yaml hosts=staging
>> >
>> > Unfortunately, that doesn't work. Right now I'm using a makefile to 
>> invoke
>> > my ansible playbooks to achieve this functionality, but I find that
>> > un-ansible-ish.
>> >
>> > Michael, would you accept merges that implemented this sort of host
>> > filtering on include statements? Would work the same as --limit on the
>> > command-line except it would be an argument to include.
>>
>> hosts: is already templateable with include arguments, so you could do
>> hosts: webservers:&$hosts
>> I think this will also lead to an error if you don't specify hosts, 
>> instead
>> of running against all of it.
>>
>>
> Cool, that works. For anybody who hits this via google, here's a complete 
> example:
>
> ping.yaml:
>
> - hosts: webservers:&$hosts
>   tasks:
>- name: ping the hosts
>  action: ping
>
> pong.yaml:
>
> # Just ping the staging server
> - include: ping.yaml hosts=staging
>
>
>
> This is a useful pattern, where's a good place to document this? 
>
> Lorin
>
>
>  
>
>> Daniel
>>
>> >  Not sure what to call it (limit, limit-hosts, hosts)?
>> >
>> >
>> > Lorin
>> >
>> >
>> > On Fri, Feb 1, 2013 at 12:55 AM, Yeukhon Wong > >
>> > wrote:
>> >
>> >> I think you can try this
>> >>
>> >> 
>> https://groups.google.com/forum/#!msg/ansible-project/qfoeqytbRE4/SI58rlzeEwMJ
>> >>
>> >> If you ever need some exception (all in this group except XX) you can
>> >> use
>> >> hosts: group1:!except_this_group
>> >>
>> >>
>> >> On Thursday, January 31, 2013 11:26:22 PM UTC-5, Lorin Hochstein wrote:
>> >>>
>> >>> When including a playbook in another playbook, is there any way to
>> >>> limit
>> >>> the hosts in the child playbook?
>> >>>
>> >>> For example, if I had an existing playbook (e.g.,
>> >>> "configure-widget.yaml") that had its hosts set to "webservers", and I
>> >>> wanted to write a playbook that only applied to the staging web 
>> server,
>> >>> is
>> >>> there any way to do something like:
>> >>>
>> >>> - include: configure-widget.yaml limit-hosts=staging
>> >>>
>> >>>
>> >>> Lorin
>> >>>
>> >>  --
>> >> 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-proje...@googlegroups.com .
>> >> For more options, visit https://groups.google.com/groups/opt_out.
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Lorin Hochstein
>> > Lead Architect - Cloud Services
>> > Nimbis Services, Inc.
>> > www.nimbisservices.com
>> >
>> > --
>> > 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-proje...@googlegroups.com .
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>> >
>>
>> --
>> 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-proje...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> -- 
> Lorin Hochstein
> Lead Architect - Cloud Services
> Nimbis Services, Inc.
> www.nimbisservices.com
>

-- 
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/fc0140fb-bbf6-4515-b23f-53645e494bda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.