user_config/tasks/main.yml

54 lines
1.8 KiB
YAML
Raw Normal View History

2018-12-02 20:03:41 +00:00
---
# tasks file for user_config
- name: clone user repository
git:
2019-04-11 16:53:38 +00:00
dest: /home/{{user.name}}/conf2 # required. The path of where the repository should be checked out. This parameter is required, unless C(clone) is set to C(no).
2019-04-16 16:32:06 +00:00
repo: "{{ user_config_repo }}" # required. git, SSH, or HTTP(S) protocol address of the git repository.
2018-12-02 20:03:41 +00:00
clone: yes # not required. If C(no), do not clone the repository if it does not exist locally
2019-04-08 21:09:14 +00:00
recursive: yes
2021-10-24 09:48:26 +00:00
force: no
2019-04-16 16:32:06 +00:00
update: yes
2018-12-02 20:03:41 +00:00
accept_hostkey: yes
2019-04-16 16:32:06 +00:00
register: config_download
- debug:
2021-10-24 09:48:26 +00:00
msg: "{{ config_download }}"
2018-12-02 20:03:41 +00:00
2022-05-31 12:13:03 +00:00
#- name: pass user shell to zsh
# user:
# name: "{{user.name}}" # required. Name of the user to create, remove or modify.
# shell: /bin/zsh # not required. Optionally set the user's shell.,On macOS, before version 2.5, the default shell for non-system users was /usr/bin/false. Since 2.5, the default shell for non-system users on macOS is /bin/bash.
# state: present # not required. choices: absent;present. Whether the account should exist or not, taking action if the state is different from what is stated.
# become: yes
2018-12-02 20:03:41 +00:00
2021-03-22 20:29:09 +00:00
- name: test if user bash rc exist
2021-10-24 09:48:26 +00:00
stat:
2022-05-31 19:25:04 +00:00
path: "{{ item }}"
2021-03-22 20:29:09 +00:00
register: links
2022-05-31 19:25:04 +00:00
with_items:
- /home/{{user.name}}/.bashrc
- /home/{{user.name}}/.zshrc
- /root/.bashrc
become: true
2021-03-22 20:29:09 +00:00
- name: delete bashrc if needed
file:
2022-05-31 19:25:04 +00:00
path: "{{ item.stat.path }}"
2021-03-22 20:29:09 +00:00
state: absent
2022-05-31 19:25:04 +00:00
when: item.stat.islnk is defined and not item.stat.islnk
with_items: "{{links.results }}"
become: true
2021-03-22 20:29:09 +00:00
2021-10-24 09:48:26 +00:00
- name: apply stow config
2018-12-02 20:03:41 +00:00
shell: stow *
args:
2019-04-11 16:53:38 +00:00
chdir: /home/{{user.name}}/conf2
2019-04-16 16:32:06 +00:00
when: config_download.changed == true
2019-04-09 17:42:12 +00:00
2019-04-16 16:32:06 +00:00
- name: apply stow config on root
2022-01-27 20:02:12 +00:00
shell: stow --t /root zsh vim git bat
2019-04-16 16:32:06 +00:00
args:
chdir: /home/{{user.name}}/conf2
when: config_download.changed == true
2022-05-31 19:25:04 +00:00
become: true