1

I work with a team of network engineers that are scared of linux, and I am trying to create a seamless user experience for my team.

How do I create a condition that says: when key authentication fails, prompt users for username and passwd?

This is what I have so far:

---

- name: Get facts from core1.site1 Junos router
  hosts: routers
  connection: local
  gather_facts: no

  roles:
    - Juniper.junos
  vars_prompt:
    - name: netconf_user
      prompt: Username
      private: no
    - name: netconf_password
      prompt: Password
      private: yes
      register: results
  vars:
    default_port: 830
  tasks:
    - name: Get Junos Facts
      junos_get_facts:
        host: "{{ inventory_hostname }}"
     ######I would like the key authentication test to happen here, please.
        user: "{{ netconf_user }}"
        port: "{{ default_port }}"
        passwd: "{{ netconf_password }}"
      register: junos_facts_result
    - name: Print Junos Facts Result
      debug:
        var: junos_facts_result
    - name: Print Junos HOME Dir
      debug:
        var: junos_facts_result.facts.HOME
    - name: Print value of default_port
      debug:
        var: default_port
techraf
  • 4,243
  • 8
  • 29
  • 44
  • 2
    Doing this would be an anti-pattern security-wise. If you want a seamless experience, ensure that your users and servers are set up properly with key authentication. Password authentication should absolutely be disabled on all of your systems anyway. – EEAA Jun 01 '17 at 13:28
  • You think so? The passwords are managed. – Louie Louie Jun 01 '17 at 13:29

0 Answers0