diff --git a/Makefile b/Makefile index 3c5feb03dadb52ed3841b5d2a6a45b58dd6b48cb..be5726762359178dad42ca3caed0e890abfeff78 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ help: # Print help on Makefile sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\e[1;33;4;40m"`\1`printf "\033[0m"` \3/" | \ expand -t20 -clean: # Remove files not tracked in source control +clean: # Remove files not in source control find . -type f -name "*.retry" -delete find . -type f -name "*.orig" -delete diff --git a/inventory.sample b/inventory.sample index 6617b7e7fa4eefaa56fc66a5f6c831c861473ec9..4af320bf594a80d813ab872ef9fc2f68b2c65b6d 100644 --- a/inventory.sample +++ b/inventory.sample @@ -79,4 +79,6 @@ timezone="Europe/Paris" user_shell=/bin/zsh [workstation:vars] +git_email=<GIT_EMAIL> +git_name=<GIT_NAME> timezone="Europe/Paris" diff --git a/tasks/user_cfg/my_user.yml b/tasks/user_cfg/my_user.yml index 426b4741c79760fbdde5b3d76915a0239f415f9e..804c200260091573b1fee3ed363e0dac16a3eaa9 100644 --- a/tasks/user_cfg/my_user.yml +++ b/tasks/user_cfg/my_user.yml @@ -20,6 +20,13 @@ loop_control: label: "{{ item | basename }}" +- name: MY USER | git config + become: true + ansible.builtin.template: + dest: "/home/{{ my_user }}/.gitconfig" + src: templates/gitconfig.j2 + mode: 0640 + - name: MY USER | ssh config become: true ansible.builtin.template: diff --git a/tasks/user_cfg/files/dotfiles/gitconfig b/tasks/user_cfg/templates/gitconfig.j2 similarity index 94% rename from tasks/user_cfg/files/dotfiles/gitconfig rename to tasks/user_cfg/templates/gitconfig.j2 index 71c1e936eab643b70be4f29fa2dcea8fa3dfebed..e771e7e03511d8c23e765ba38af291181c77eb56 100644 --- a/tasks/user_cfg/files/dotfiles/gitconfig +++ b/tasks/user_cfg/templates/gitconfig.j2 @@ -47,3 +47,7 @@ [init] defaultBranch = stable + +[user] + name = "{{ git_name }}" + email = "{{ git_email }}" diff --git a/tasks/user_cfg/templates/ssh-config.j2 b/tasks/user_cfg/templates/ssh-config.j2 new file mode 100644 index 0000000000000000000000000000000000000000..a4cd8b8551a583bcc321cd41b419875993b6ef65 --- /dev/null +++ b/tasks/user_cfg/templates/ssh-config.j2 @@ -0,0 +1,43 @@ +#jinja2:lstrip_blocks: True +# ############################################# # +# This file is managed by Ansible # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['backup'] %} +# WAN + {% for host in groups['production'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['production'] %} +# BKP + {% for host in groups['backup'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] %} +# DEV + {% for host in groups['devel'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} + +# LOCAL + {% for host in groups['station'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} diff --git a/tasks/user_cfg/templates/ssh_config.j2 b/tasks/user_cfg/templates/ssh_config.j2 deleted file mode 100644 index 331ab2a606868abadfb281129da020ffda23ee9a..0000000000000000000000000000000000000000 --- a/tasks/user_cfg/templates/ssh_config.j2 +++ /dev/null @@ -1,13 +0,0 @@ -#jinja2:lstrip_blocks: True -# ############################################# # -# This file is managed by Ansible # -# https://lab.frogg.it/freezed/ansible-debian # -# ############################################# # - -{% for host in groups['all'] %} -Host {{ host }} - User {{ hostvars[host]['my_user'] }} - Hostname {{ hostvars[host]['ansible_host'] }} - Port {{ hostvars[host]['ansible_port'] }} - -{% endfor %}