Set up authorized_keys for purely new machine.

25 views
Skip to first unread message

Andrey Voronkov

unread,
Sep 8, 2015, 9:31:58 AM9/8/15
to ansible...@googlegroups.com
Hello community,
I'm at very beginning of ansible understanding for now. And main goal is to get proper keys for set of users on a new server. And work in normal mode after.
Given: some server which have password ssh access for root (or sudoer like azureuser for Microsoft Azure).
Goal: setup ~/.ssh/authorized_keys  for set of users e.g. root, azureuser, deploy.
Problem: How to run particular task with prompted user and prompted password.

Now I have a file with just one plain task:

---
- name: Set up authorized_keys for the deploy user
  authorized_key:
    user: "{{ item }}"
    key: "{{ lookup('file', 'configs/authorized_keys') }}"
    state: present
    exclusive: yes
    manage_dir: yes
  with_items: "{{ users_to_setup }}"

And a playbook file:

---
- hosts: all
  vars:
    users_to_setup:
      - root
      - deploy
      - azureuser
  tasks:
  - include: "common/server_setup.yml"

I run playbook file and I want interactively ask bootstrap_user and bootstrap_password and then provide proper variables to the task in server_setup to run this scenario using this bootstrap user. All other tasks in playbook I want to run from root or deploy but with keys set up.

Reply all
Reply to author
Forward
0 new messages