Hi David,

Changing the yml file as below at least loads the file. As per docs the key
under responses is python regex so I think it should work.

- name: Access member 0
  expect:
    command: 'request session member 0'
    responses:
      ^---\sJUNOS.+\n(warning.+\n){5}\{((backup)|(linecard)):((1)|(2))\}:
start shell user root


However, I am trying to understand the need to use 'expect' module to run
junos operational command.
Can't it be run using 'junos_command' module? Does running this command
prompts for an interactive input?

Regards,
Ganesh

On Tue, Feb 28, 2017 at 6:29 PM, David Williams <[email protected]>
wrote:

> Thank you Matt, I have looked at the modules but I'm trying to drop down
> into the linux shell and change some file permissions within the directory
> structure.  It doesn't look like the module can do that.  Thanks for trying
> though!  Any help is always appreciated.
>
>
> On Tuesday, February 28, 2017 at 12:22:13 AM UTC-6, Matt Clay wrote:
>>
>> David,
>>
>> I know this isn't what you asked, but since it looks like you're working
>> with JUNOS I thought I'd check to see if you've already looked at Ansible's
>> JUNOS support:
>>
>> https://docs.ansible.com/ansible/list_of_network_modules.html#junos
>>
>>  - Matt
>>
>> On Monday, February 27, 2017 at 3:57:16 PM UTC-8, David Williams wrote:
>>>
>>> I am stumped...I have been trying to use the expect module and format
>>> the expected response as a regex that can match multiple responses.   I see
>>> posts all over where people are trying to match the response exactly and
>>> have to escape the regex special characters.  It seems nobody writes regex
>>> to match multiple responses.  Is this not possible?
>>>
>>> *Playbook*
>>>
>>> - name: Clear Permissions on /var/etc/pam.conf
>>>   hosts: juniper_ex4200
>>>   tasks:
>>>     - name: Access member 0
>>>       expect:
>>>         command: 'request session member 0'
>>>         responses: "^---\sJUNOS.+\n(warning.+\n){
>>> 5}\{((backup)|(linecard)):((1)|(2))\}": "start shell user root"
>>>
>>>
>>> *Error*
>>>
>>> ERROR! Syntax Error while loading YAML.
>>>
>>>
>>> The error appears to have been in '/home/dwilliams/ex4200_permis
>>> sions_clear/ex4200_permissions_clear': line 8, column 25, but may
>>> be elsewhere in the file depending on the exact syntax problem.
>>>
>>> The offending line appears to be:
>>>
>>>         command: 'request session member 0'
>>>         responses: "^---\sJUNOS.+\n(warning.+\n){
>>> 5}\{((backup)|(linecard)):((1)|(2))\}"
>>>                         ^ here
>>> This one looks easy to fix.  It seems that there is a value started
>>> with a quote, and the YAML parser is expecting to see the line ended
>>> with the same kind of quote.  For instance:
>>>
>>>     when: "ok" in result.stdout
>>>
>>> Could be written as:
>>>
>>>    when: '"ok" in result.stdout'
>>>
>>> Or equivalently:
>>>
>>>    when: "'ok' in result.stdout"
>>>
>>> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/8953d535-057d-48ea-8908-157fd4cb2cdb%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/8953d535-057d-48ea-8908-157fd4cb2cdb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFyXTfJxg0jRrB6FjnUHSLWGxUpHcUxoLXdwAcHug6_5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to