Re: [ansible-project] How to use a variable inside of a regex string? (search filter)

2017-11-03 Thread coolcps
Works, thank you!

On Friday, November 3, 2017 at 11:32:36 AM UTC-7, Kai Stian Olstad wrote:
>
> On 03. nov. 2017 18:14, coo...@gmail.com  wrote: 
> > It looks like this is working, but I get an error.  Does anyone know the 
> > proper way to do this?  Thanks! 
> > 
> > 
> > - name: configure hostname 
> >ios_config: 
> >  commands: 
> >- ip domain-name {{ domain_name }} 
> >when: not ansible_net_config | search("(ip domain-name {{ domain_name 
> }}|ip domain name {{ domain_name }})" 
>
>
> According to the template documentation[1] ~ (tilde) is used for 
> concatenation of strings, so is just a matter of concatenate the elements. 
>
> when: not ansible_net_config | search("(ip domain-name " ~ domain_name ~ 
> "|ip domain name " ~ domain_name ~ ")") 
>
>
> [1] http://jinja.pocoo.org/docs/dev/templates/#other-operators 
>
> -- 
> Kai Stian Olstad 
>

-- 
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/59e25727-bdb4-4ecb-b86b-005e56bad458%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to use a variable inside of a regex string? (search filter)

2017-11-03 Thread coolcps
It looks like this is working, but I get an error.  Does anyone know the 
proper way to do this?  Thanks!


- name: configure hostname
  ios_config:
commands:
  - ip domain-name {{ domain_name }}
  when: not ansible_net_config | search("(ip domain-name {{ domain_name }}|ip 
domain name {{ domain_name }})")



 [WARNING]: when statements should not include jinja2 templating delimiters 
such as {{ }} or {% %}. Found: not ansible_net_config | search("(ip 
domain-name {{ domain_name }}|ip domain name {{
domain_name }})")

-- 
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/610b3769-5894-4dc4-b9f1-4327d358f5ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: tags within included_tasks do not work?

2017-11-02 Thread coolcps
Figured this out, need to use import_tasks or tags don't work under it.  
Reading this 
documentation 
https://docs.ansible.com/ansible/2.4/playbooks_reuse.html#differences-between-static-and-dynamic
 
and not sure if its a bug or meant to be that way.

On Thursday, November 2, 2017 at 4:49:14 PM UTC-7, coo...@gmail.com wrote:
>
> In a playbook I have a file of tasks included, like so:
>
> - include_tasks: uplinks.yml
>
> And within that task file I have a task:
>
>
> - name: configure hosts
>   ios_config:
> commands:
>   - ip host {{ item['name'] }} {{ item['port'] }} {{ 
> interfaces['mgmt']['ip'] }}
>   with_items: "{{ host_entries }}"
>   tags: update_ts_hosts
>
>
>
> If I try to run the playbook with only that tag, no tasks will run. If I 
> move the tag to the included_tasks level, then all tasks under will run. 
>
>
> ie
>
>
> - include_tasks: misc.yml
>
>   tags: update_ts_hosts
>
>
> I would like to be able to pick specific tasks out of included files, is 
> there something I am missing here?  Thanks for any info!
>
>

-- 
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/4e4e63a7-c4a4-42c5-896e-85cb6d97e5d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] tags within included_tasks do not work?

2017-11-02 Thread coolcps
In a playbook I have a file of tasks included, like so:

- include_tasks: uplinks.yml

And within that task file I have a task:


- name: configure hosts
  ios_config:
commands:
  - ip host {{ item['name'] }} {{ item['port'] }} {{ 
interfaces['mgmt']['ip'] }}
  with_items: "{{ host_entries }}"
  tags: update_ts_hosts



If I try to run the playbook with only that tag, no tasks will run. If I 
move the tag to the included_tasks level, then all tasks under will run. 


ie


- include_tasks: misc.yml

  tags: update_ts_hosts


I would like to be able to pick specific tasks out of included files, is there 
something I am missing here?  Thanks for any info!

-- 
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/a9db896c-07a3-4aac-af71-66325252570f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] network_cli.py help

2017-09-23 Thread coolcps
Exactly what I needed, thanks for the help!

On Saturday, September 23, 2017 at 12:26:59 AM UTC-7, Ganesh Nalawade wrote:
>
>
> If I understand the question correctly you want to access port value 
> within network_cli.py, if yes you can do it by accessing
> self._play_context.port
>
> Regards,
> Ganesh
>
> On Sat, Sep 23, 2017 at 4:42 AM,  wrote:
>
>> Would anyone happen to know if the ansible_port variable is accessible 
>> anywhere in this module?  I'd like to make an update (for personal use) 
>> that differentiates an action based on port.  Thanks for any info!
>>
>> -- 
>> 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/48e457f9-62e0-473f-8996-71df4b06c1f4%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/f593062b-3618-4ef7-8280-fd2643e30852%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] network_cli.py help

2017-09-22 Thread coolcps
Would anyone happen to know if the ansible_port variable is accessible 
anywhere in this module?  I'd like to make an update (for personal use) 
that differentiates an action based on port.  Thanks for any info!

-- 
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/48e457f9-62e0-473f-8996-71df4b06c1f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Connecting to Cisco IOS device through Cisco terminal server (29xx)

2017-07-10 Thread coolcps
I would like Ansible to connect to the console port of IOS devices to 
provision them.  I have set up a Cisco 29xx terminal server to use SSH. 
 The issue is that in order to access the device, you must now go through 
two prompts.  The first prompt username/password, then hit Enter to bring 
up the second prompt.  From here it is like logging into the device as 
normal.


Is there anyway to use the current ios modules (facts, command, config, 
etc) to login in this manner?  Or are there any other solutions?  Thanks 
for any assistance!

-- 
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/5df83e91-73a1-48bc-a29d-17b56c3e7ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.