This commit is contained in:
parent
16b7760ae4
commit
43c981e4e2
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
# defaults file for user_config
|
# defaults file for user_config
|
||||||
|
|
||||||
user:
|
user_config_username: root
|
||||||
name: vincent
|
|
||||||
|
|
||||||
user_config_repo: ssh://git@git.{{ domain.name }}:2222/vincent/conf2.git
|
user_config_repo: "ssh://toto@domaine.foo:port/root/conf.git"
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
---
|
---
|
||||||
# handlers file for user_config
|
# handlers file for user_config
|
||||||
|
- name: Apply stow config
|
||||||
|
ansible.builtin.shell: stow {{user_config_stow_module}}
|
||||||
|
args:
|
||||||
|
chdir: '{{user_config_home}}/conf2'
|
||||||
|
|
||||||
|
@ -1,53 +1,27 @@
|
|||||||
---
|
---
|
||||||
# tasks file for user_config
|
# tasks file for user_config
|
||||||
- name: clone user repository
|
- name: Clone user repository
|
||||||
git:
|
ansible.builtin.git:
|
||||||
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).
|
dest: "{{ user_config_home }}"
|
||||||
repo: "{{ user_config_repo }}" # required. git, SSH, or HTTP(S) protocol address of the git repository.
|
repo: "{{ user_config_repo }}"
|
||||||
clone: yes # not required. If C(no), do not clone the repository if it does not exist locally
|
clone: true
|
||||||
recursive: yes
|
recursive: true
|
||||||
force: no
|
force: false
|
||||||
update: yes
|
update: true
|
||||||
accept_hostkey: yes
|
accept_hostkey: true
|
||||||
register: config_download
|
notify: Apply stow config
|
||||||
|
|
||||||
- debug:
|
- name: Test if user bash rc exist
|
||||||
msg: "{{ config_download }}"
|
ansible.builtin.stat:
|
||||||
|
path: '{{ item }}'
|
||||||
#- 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
|
|
||||||
|
|
||||||
- name: test if user bash rc exist
|
|
||||||
stat:
|
|
||||||
path: "{{ item }}"
|
|
||||||
register: links
|
register: links
|
||||||
with_items:
|
with_items:
|
||||||
- /home/{{user.name}}/.bashrc
|
- /{{ user_config_home }}/.bashrc
|
||||||
- /home/{{user.name}}/.zshrc
|
- /{{ user_config_home }}/.zshrc
|
||||||
- /root/.bashrc
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: delete bashrc if needed
|
- name: Delete bashrc if needed
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ item.stat.path }}"
|
path: '{{ item.stat.path }}'
|
||||||
state: absent
|
state: absent
|
||||||
when: item.stat.islnk is defined and not item.stat.islnk
|
when: item.stat.islnk is defined and not item.stat.islnk
|
||||||
with_items: "{{links.results }}"
|
with_items: '{{ links.results }}'
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: apply stow config
|
|
||||||
shell: stow *
|
|
||||||
args:
|
|
||||||
chdir: /home/{{user.name}}/conf2
|
|
||||||
when: config_download.changed == true
|
|
||||||
|
|
||||||
- name: apply stow config on root
|
|
||||||
shell: stow --t /root zsh vim git bat
|
|
||||||
args:
|
|
||||||
chdir: /home/{{user.name}}/conf2
|
|
||||||
when: config_download.changed == true
|
|
||||||
become: true
|
|
||||||
|
@ -1,2 +1,14 @@
|
|||||||
---
|
---
|
||||||
# vars file for user_config
|
# vars file for user_config
|
||||||
|
|
||||||
|
user_config_home: "{% if user_config_username == 'root' %}\
|
||||||
|
/{{user_config_username}}\
|
||||||
|
{% else %}\
|
||||||
|
/home/{{user_config_username}}\
|
||||||
|
{% endif%}"
|
||||||
|
|
||||||
|
user_config_stow_module: "{% if user_config_username == 'root' %}\
|
||||||
|
zsh git vim bat\
|
||||||
|
{% else %}\
|
||||||
|
*\
|
||||||
|
{% endif %}"
|
||||||
|
Loading…
Reference in New Issue
Block a user