Ansible authorized key module unable to read public key

前端 未结 2 474
无人共我
无人共我 2021-01-27 11:35

I\'m trying to use ansible (version 2.1.2.0) to create named ssh access across our network of servers. Running ansible from a jump box I\'m creating a set of users and creating

2条回答
  •  我在风中等你
    2021-01-27 12:33

    OK, the problem is with lookup plugin.
    It is executed on ansible control host with permissions of user that run ansible-playbook and become: yes don't elevate plugins' permissions.

    To overcome this, capture result of user task and use its output in further tasks:

    - user:
        name: "{{ item }}"
        shell: /bin/bash
        group: docker
        generate_ssh_key: yes
        ssh_key_comment: "ansible-generated for {{ item }}"
      with_items:
        - ansible5
        - ansible6
      register: new_users
      become: yes
    
    - debug: msg="user {{ item.item }} pubkey {{ item.ssh_public_key }}"
      with_items: "{{ new_users.results }}"
    

    Although you need to delegate some of this tasks, the idea will be the same.

提交回复
热议问题