Here the code to make the CLI configuration:

*  - name: Launch the CLI first time*
*    expect:*
*      command: telnet 0 2200*
*      responses:*
*        login: "user"*
*        Password: "passwd"*
*        Press any key to continue\.: ""*
*        Enable Secure Backup mode.*: "n"*
*        Enable Common Criteria Compatibility mode.*: "n"*
*        Please enter new password.*: "new_password!"*
*        Please re-enter new password to confirm.*: "new_password!"*
*        idg#:*
*          - configure terminal*
*          - exit*
*        idg\(config\)#:*
*          - web-mgmt*
*          - write memory*
*          - "exit"*
*        idg\(config web-mgmt\)#:*
*          - "admin-state enabled"*
*          - "local-address <host> <port>"*
*          - "exit"*
*    register: result*
*    failed_when: result.rc > 1*
*    tags:*
*       - cli*
this code perform these actions:

1)Access the cli with telnet 0 2200
2)insert default username and password
3)Press enter
4)Answer No to a couple of questions
5)add new password and confirm it again
6) then start with configuration:


   - configure terminal
   - web-mgmt
   - admin-state enabled
   - local-address host port
   - exit
   - write memory
   - exit

A tag "cli" is added in case to run only the last step, indeed this is the 
last step of a larger playbook

Hoping to help someone.

Regards

On Wednesday, 15 November 2017 15:07:58 UTC+1, [email protected] 
wrote:
>
> HI
>
> I created an ansble role which install on the target hosts IBM api connect 
> gateways software and enable the service.
> I would improve this role adding configuration steps.
>
> After the installation the APIC gateways need to be configured accessing 
> to a dedicated command line interface, the first access is made of the 
> following steps:
>
> $ telnet 0 2200      *//command to launch to access the CLI*
> Trying 0.0.0.0...
> Connected to 0.
> Escape character is '^]'.
> stefano2.prv
> Unauthorized access prohibited.
>
> login: user          *//here i need to write the username*
> Password: *****  *// as well as the password*
>
> ****************************************************************
> ATTENTION: Use care when making your selections for operational
> modes. If you select an incorrect mode for your environment,
> the only way to change an operational mode is to reinitialize
> the appliance.
>
> Press any key to continue.
> ****************************************************************
>
> I'm stuck here, i tried to add these lines:
>
>  * - name: Launch the CLI first time*
> *    expect:*
> *      command: telnet 0 2200*
> *      responses:*
> *        Question:*
> *          login: "user"*
> *          Password: "password"*
> *          Press any key to continue.: /bin/bash -c "echo"*
>
> Every time i try to run the role i gt this error at the end:
>
> *TASK [Launch the CLI first time] 
> *************************************************************************************************************************************************************************
> *fatal: [stefano3]: FAILED! => {"changed": false, "failed": true, "msg": 
> "The pexpect python module is required"}*
> *fatal: [stefano2]: FAILED! => {"changed": false, "failed": true, "msg": 
> "The pexpect python module is required"}*
> *        to retry, use: --limit @/etc/ansible/api_gateways/apigw.retry*
>
> Could you help me? 
> How can i answer to the "Press any key to continue"? 
>
> Or maybe there are further errors i did not get in the previous steps.
>
>
>

-- 
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/16c4a68a-6ccf-46e2-b478-66387e35d7c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to