roles/user/tasks/main.yml

Sun, 14 Jul 2019 03:09:40 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 14 Jul 2019 03:09:40 -0500
changeset 90
48ec8001075f
parent 89
86248a83a3dd
child 93
14e0c774b916
permissions
-rw-r--r--

Remove lightdm changes

---
# 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: "User authorized_keys"
  authorized_key:
    manage_dir: true
    user: "{{ user_name }}"
    key: "{{ item }}"
  with_file:
    - public_keys/{{ user_name }}
  tags: user, ssh

- name: "Clone dotfiles"
  become: true
  become_user: "{{ user_name }}"
  shell: >
    hg clone -U {{ dotfiles_default | quote }} _dotfiles_
    && mv _dotfiles_/.hg .
    && rmdir _dotfiles_
    && hg -R ~ update -C master
  args:
    chdir: "{{ user.home }}"
    creates: "{{ user.home }}/.hg"
  tags: user, dotfiles

- name: "Dotfiles hg sources"
  become: true
  become_user: "{{ user_name }}"
  ini_file:
    dest: "{{ user.home }}/.hg/hgrc"
    section: paths
    option: "{{ item.name }}"
    value:  "{{ item.url }}"
    mode: 0640
    create: no
  with_items:
    - {name: 'default',      url: "{{ dotfiles_default }}"}
    - {name: 'default-push', url: "{{ dotfiles_default_push }}"}
  tags: user, dotfiles

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

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

mercurial