roles/user/tasks/main.yml

Wed, 14 Jun 2017 21:25:06 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 14 Jun 2017 21:25:06 -0400
changeset 51
5af98666f4d4
parent 50
8be666ca059e
child 54
2a04e6d7bfcc
permissions
-rw-r--r--

Make sure we don't try to install vim-nox and vim-gtk every pass

---
# Create/update my user, don't clobber my extra groups.
- name: User setup
  user:
    name: "{{user.name}}"
    comment: "{{user.comment}}"
    shell: /bin/zsh
    groups: sudo
    append: true
  register: user
  tags: user

- name: "ssh : Pubkey for user"
  authorized_key:
    manage_dir: true
    user: "{{user.name}}"
    key: "{{item}}"
  with_file:
    - public_keys/{{user.name}}
  tags: user, ssh

- name: Clone dotfiles
  become: "{{user.name}}"
  shell: >
    hg clone -U {{dotfiles_repository | quote}} _dotfiles_
    && mv _dotfiles_/.hg .
    && rmdir _dotfiles_
    && hg -R ~ update -C master
  args:
    chdir: "~"
    creates: "~/.hg"

- name: Update dotfiles
  become: "{{user.name}}"
  command: hg pull -u
  args:
    chdir: "~"
  register: update_dotfiles
  changed_when: update_dotfiles.stdout | match("added|updated")
  failed_when: update_dotfiles.rc > 1

- name: Run bin/homedir-setup
  become: "{{user.name}}"
  shell: bin/homedir-setup
  args:
    chdir: "~"
  register: homedir_setup
  changed_when: homedir_setup.stdout | match("Updating|Cloning")
  failed_when: homedir_setup.rc != 0

mercurial