On Friday, June 27, 2014 9:12:52 AM UTC-7, Michael DeHaan wrote:
>
> "This is of course all solvable by copying my dotfiles over; I could even 
> create an account with my name. I haven't bothered to do this, because I'm 
> lazy to do this manually"
>
> Write a playbook?  :)
>

Yes. I would like to do this. I kinda sorta have the beginnings of 
something, but it's perhaps a little clunky. My playbook has:

  vars_files:
  - group_vars/user.yml

and then group_vars/user.yml has my local settings:

invoking_user:
  name: marca
  full_name: Marc Abramowitz
  uid: 502
  home: /Users/marca
  ssh_public_key: /Users/marca/.ssh/id_rsa.pub

and then I do this in my playbook:

  tasks:
  - name: Create user for invoking user
    sudo: true
    # debug: var=invoking_user
    user:
      name: "{{ invoking_user.name }}"
      comment: "{{ invoking_user.full_name }}"
      uid: "{{ invoking_user.uid }}"
    tags:
    - user

  - name: Set authorized_key for invoking user
    sudo: true
    authorized_key:
      user: "{{ invoking_user.name }}"
      key: "{{ lookup('file', invoking_user.ssh_public_key) }}"
    tags:
    - user

I would've preferred something more automatic, but I guess I could always 
have a simple Python configure.py script that generates group_vars/user.yml
 

> Most people would keep their dotfiles as a repo, managed centrally, rather 
> than trying to discover them.
>
> It's more explicit, and translates over to Ansible easier than trying to 
> discover them from some arbitrary remote system, copy them back, move them 
> to the other, etc.
>

Yeah that's a good point. And in fact I do have my dotfiles in a git repo, 
so maybe checking them out is better. The alternative is to rsync them from 
the host running ansible.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8d08ced5-5b82-4f06-908f-e2290fdef822%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to