diff --git a/tasks/become_user_cfg.yml b/tasks/become_user_cfg.yml index 48b4f7d8067ddd1caed02ee3dcaa549b60c8891b..90116cd96fb384a74294b9263639d03ef4fef49a 100644 --- a/tasks/become_user_cfg.yml +++ b/tasks/become_user_cfg.yml @@ -21,10 +21,12 @@ - name: SUDO | User presence (with groups) become: true ansible.builtin.user: + append: true + groups: sudo name: "{{ my_user }}" + shell: "{{ user_shell }}" state: present - groups: sudo - append: true + uid: 1000 - name: SUDO | Reset ansible connection to apply group update become: true diff --git a/tasks/user_cfg/files/dotfiles/bash_login b/tasks/user_cfg/files/dotfiles/bash_login new file mode 100644 index 0000000000000000000000000000000000000000..78293061a58b54ea8a4b7ddae5e0f7dc9030597a --- /dev/null +++ b/tasks/user_cfg/files/dotfiles/bash_login @@ -0,0 +1,23 @@ +# ############################################# # +# This file is managed by Ansible # +# Manual edition will be overridden # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +USAGE_FILE=/var/.usage + +lsb_release -d | sed 's/Description:/-=VERSION=-\t/g' + +echo -e "-=UPTIME=-\t $(uptime)\n" + +echo -e "-=WHOisHERE=-\n $(w)\n" + +echo -e "\n-=IPs=-\n $(ip -br address|grep UP)\n" + +echo -e "-=SCREEN=-\n $(screen -list)" + +echo -e "-=DISKSPACE=-" +[[ -n $(zpool list) ]] &> /dev/null && zpool list -o name,size,free,frag,cap,health || df -h -t ext4 --output=source,used,avail,target + +echo -e "\n-=USAGE=-" +[[ -e $USAGE_FILE ]] && cat ${USAGE_FILE} || echo "Usage unknown" diff --git a/tasks/user_cfg/files/dotfiles/bashrc b/tasks/user_cfg/files/dotfiles/bashrc new file mode 100644 index 0000000000000000000000000000000000000000..0d762d839dfed7565ce9c19b4cc00b5394ce5101 --- /dev/null +++ b/tasks/user_cfg/files/dotfiles/bashrc @@ -0,0 +1,7 @@ +# ############################################# # +# This file is managed by Ansible # +# Manual edition will be overridden # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +# Ensure the remote shell produces no output for non-interactive sessions diff --git a/tasks/user_cfg/files/dotfiles/gitconfig b/tasks/user_cfg/files/dotfiles/gitconfig index cd596e9f49f6a44722855a7eff48436e19bc87d4..71c1e936eab643b70be4f29fa2dcea8fa3dfebed 100644 --- a/tasks/user_cfg/files/dotfiles/gitconfig +++ b/tasks/user_cfg/files/dotfiles/gitconfig @@ -1,11 +1,6 @@ # ############################################# # -# ~/.gitconfig # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # [color] @@ -23,7 +18,8 @@ fp = fetch --prune lga = log --graph --oneline --decorate --since=10days --all lgla = log --graph --oneline --decorate --date=short --all - lg = log --graph --oneline --decorate --since=10days + lg1 = log --max-count=1 --stat + lg2 = log --max-count=2 --stat st = status [mergetool] @@ -37,6 +33,9 @@ [checkout] defaultRemote=origin +[url "ssh://git@git.afpy.org/"] + pushInsteadOf = https://git.afpy.org/ + [url "ssh://git@github.com/"] pushInsteadOf = https://github.com/ diff --git a/tasks/user_cfg/files/dotfiles/profile b/tasks/user_cfg/files/dotfiles/profile new file mode 100644 index 0000000000000000000000000000000000000000..4a4ba02a61ae14128590f92edc349ab50062bb3c --- /dev/null +++ b/tasks/user_cfg/files/dotfiles/profile @@ -0,0 +1,6 @@ +# ############################################# # +# This file is managed by Ansible # +# Manual edition will be overridden # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # +echo "DEBUG: I am .profile" diff --git a/tasks/user_cfg/files/dotfiles/vimrc b/tasks/user_cfg/files/dotfiles/vimrc index 086b5543282a8ba75dfa5b1c4046ed0322d74110..07c27a08267e4a1dcecbef5dc129afd650395a2c 100644 --- a/tasks/user_cfg/files/dotfiles/vimrc +++ b/tasks/user_cfg/files/dotfiles/vimrc @@ -1,12 +1,6 @@ " """"""""""""""""""""""""""""""""""""""""""""" " -" ~/.vimrc " -" " " This file is managed by Ansible " -" Manual edition will be overridden " -" " " https://lab.frogg.it/freezed/ansible-debian " -" http://formation-debian.via.ecp.fr/ " -" " " """"""""""""""""""""""""""""""""""""""""""""" " " ':help options.txt' ou ':help nom_du_paramètre' dans Vim diff --git a/tasks/user_cfg/files/dotfiles/zlogin b/tasks/user_cfg/files/dotfiles/zlogin index fe6db75cb8e6b2eccff6afe8912654733f099ff3..960bb838f3cc0f7523317a7cb6b3edbfd2b60741 100644 --- a/tasks/user_cfg/files/dotfiles/zlogin +++ b/tasks/user_cfg/files/dotfiles/zlogin @@ -1,11 +1,6 @@ # ############################################# # -# ~/.zlogin # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # USAGE_FILE=/var/.usage diff --git a/tasks/user_cfg/files/dotfiles/zlogout b/tasks/user_cfg/files/dotfiles/zlogout index d2323a0468270cb3f255d5b9b18ddb4057033288..0b9f8938f7aa33bc5f375c8e674397deeaf856d4 100644 --- a/tasks/user_cfg/files/dotfiles/zlogout +++ b/tasks/user_cfg/files/dotfiles/zlogout @@ -1,11 +1,6 @@ # ############################################# # -# ~/.zlogout # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # echo "Exiting ${HOSTNAME}…" diff --git a/tasks/user_cfg/files/dotfiles/zshenv b/tasks/user_cfg/files/dotfiles/zshenv index d22f1b3f25cdcd27d7f9f4fb5af368542a7d5fb8..422671003648fa7479a687456aa6991066ff6cef 100644 --- a/tasks/user_cfg/files/dotfiles/zshenv +++ b/tasks/user_cfg/files/dotfiles/zshenv @@ -1,11 +1,6 @@ # ############################################# # -# ~/.zshenv # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # export PATH="/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/sbin:$HOME/bin:$HOME/.local/bin" diff --git a/tasks/user_cfg/files/dotfiles/zshrc b/tasks/user_cfg/files/dotfiles/zshrc index 0a597e1d4f0960053aa0528f95413934bcaebad6..1720df7499f42a79fcab0d70c336a415fe57875b 100644 --- a/tasks/user_cfg/files/dotfiles/zshrc +++ b/tasks/user_cfg/files/dotfiles/zshrc @@ -1,12 +1,6 @@ # ############################################# # -# ~/.zshrc # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# from http://formation-debian.via.ecp.fr # -# # # ############################################# # @@ -35,12 +29,10 @@ function gh() { grep --color "$1" ~/.history } alias ada='sudo apt update && sudo apt list --upgradable && sudo apt clean' alias agr='sudo apt upgrade && sudo apt autoclean && sudo apt autoremove' alias apti='sudo apt install' -alias p1='ping -c 1 ' alias gps='for proj in $(find ~/git -mindepth 1 -maxdepth 1 -type d -printf "%p\n");do RES=$(git -C ${proj} status -s) && [[ -n ${RES} ]] && echo "\n# ${proj#${HOME}/git/}:\n${RES}";done' alias gpu='for proj in $(find ~/git -mindepth 1 -maxdepth 1 -type d -printf "%p\n");do git -C ${proj} fetch --prune --quiet || echo "ERROR fetching git repo: ${proj#${HOME}/git/}";done' alias p1='ping -c 1 ' alias sudo='sudo ' -alias ttoday='cat ~/.timed|grep "$(date +%d) Oct 2021" | timed parse' alias vact='source ~/.venvs/$(pwd | cut -d"/" -f5)/bin/activate' alias vc10='~/pylocal/bin/python3.10 -m venv --clear --copies ~/.venvs/$(pwd | cut -d "/" -f5)' alias vc='python3 -m venv --clear --copies ~/.venvs/$(pwd | cut -d "/" -f5)' @@ -49,7 +41,7 @@ alias vdestroy='VENV_PATH="${HOME}/.venvs/$(pwd | cut -d"/" -f5)/" && echo ${VEN # Timed alias tart='timed start _job_;vi ~/.timed +' alias tsto='timed stop;ttod' -alias ttod='cat ~/.timed | grep "$(date +%d) Jan 2022" | timed parse' +alias ttod='cat ~/.timed | grep "$(date +%d) Jan 2023" | timed parse' # ######################### # @@ -194,7 +186,7 @@ unsetopt hup # ########################################### # setopt EXTENDED_HISTORY -export HISTTIMEFORMAT="[%F %T] " +#export HISTTIMEFORMAT="[%F %T] " # Nombre d'entrées dans l'historique export HISTORY=50000 diff --git a/tasks/user_cfg/main.yml b/tasks/user_cfg/main.yml index f3f9265aca373272afe744a81866bab970fe2dab..e27e3b5e7a391bd90f731444aad3ca16d73f5f04 100644 --- a/tasks/user_cfg/main.yml +++ b/tasks/user_cfg/main.yml @@ -6,7 +6,16 @@ tasks: - - name: "IMPORT_TASKS | root" + - name: USER CONFIG | install zsh + when: inventory_hostname in groups.workstat + ansible.builtin.apt: + cache_valid_time: 3600 + force_apt_get: true + pkg: zsh + state: present + update_cache: true + + - name: IMPORT_TASKS | root ansible.builtin.import_tasks: root.yml - name: "IMPORT_TASKS | {{ my_user }}" diff --git a/tasks/user_cfg/my_user.yml b/tasks/user_cfg/my_user.yml index 3e0354b5cc6363f74697e1aeebd5a3ec4b722426..426b4741c79760fbdde5b3d76915a0239f415f9e 100644 --- a/tasks/user_cfg/my_user.yml +++ b/tasks/user_cfg/my_user.yml @@ -1,7 +1,14 @@ --- +- name: MY USER | set user + become: no + ansible.builtin.user: + name: "{{ my_user }}" + shell: "{{ user_shell }}" + state: present + uid: 1000 - name: MY USER | dotfiles - become: yes + become: true ansible.builtin.copy: src: "{{ item }}" dest: "/home/{{ my_user }}/.{{ item | basename }}" @@ -14,15 +21,43 @@ label: "{{ item | basename }}" - name: MY USER | ssh config - become: yes + become: true ansible.builtin.template: dest: "/home/{{ my_user }}/.ssh/config" - src: templates/ssh_config.j2 + src: templates/ssh-config.j2 mode: 0640 -- name: MY USER | git directory presence - become: yes +- name: "MY USER | authorized_key for «{{ my_user }}»" + become: true + ansible.builtin.authorized_key: + comment: "Managed by Ansible" + key: https://gitlab.com/free_zed.keys + state: present + user: "{{ my_user }}" + +- name: MY USER | osm cache dir presence + become: true + when: inventory_hostname in groups.station + ansible.builtin.file: + group: "{{ my_user }}" + mode: '0750' + owner: "{{ my_user }}" + path: "/home/{{ my_user }}/.osm-tiles/" + state: directory + +- name: MY USER | gps prune config + become: true when: inventory_hostname in groups.station + ansible.builtin.template: + src: templates/pruneconfig.j2 + dest: "/home/{{ my_user }}/.pruneconfig" + owner: "{{ my_user }}" + group: "{{ my_user }}" + mode: '0640' + +- name: MY USER | git directory presence + become: true + when: inventory_hostname in groups.workstat ansible.builtin.file: group: "{{ my_user }}" mode: '0750' @@ -31,38 +66,18 @@ state: directory - name: INCLUDE_VARS | git - when: inventory_hostname in groups.station + when: inventory_hostname in groups.workstat ansible.builtin.include_vars: "vars/git.yml" - name: MY USER | clone git repos - become: yes - when: inventory_hostname in groups.station + become: true + when: inventory_hostname in groups.workstat ansible.builtin.git: dest: "/home/{{ my_user }}/git/{{ item.local_name }}" repo: "{{ item.url_https }}" remote: "origin" update: no - accept_hostkey: yes + accept_hostkey: true with_items: "{{ git_repositories }}" loop_control: label: "{{ item.local_name }}" - -- name: MY USER | osm cache dir presence - become: yes - when: inventory_hostname in groups.station - ansible.builtin.file: - group: "{{ my_user }}" - mode: '0750' - owner: "{{ my_user }}" - path: "/home/{{ my_user }}/.osm-tiles/" - state: directory - -- name: MY USER | gps prune config - become: yes - when: inventory_hostname in groups.station - ansible.builtin.template: - src: templates/pruneconfig.j2 - dest: "/home/{{ my_user }}/.pruneconfig" - owner: "{{ my_user }}" - group: "{{ my_user }}" - mode: '0640' diff --git a/tasks/user_cfg/root.yml b/tasks/user_cfg/root.yml index d55dca4ec86c0a8063e99f2bb8159c0e47ed4b31..7718802b602a8a3735fdf04c927ab905309844bf 100644 --- a/tasks/user_cfg/root.yml +++ b/tasks/user_cfg/root.yml @@ -1,4 +1,10 @@ --- +- name: ROOT | set user + become: no + ansible.builtin.user: + name: root + shell: "{{ user_shell }}" + state: present - name: ROOT | dotfiles become: no @@ -13,9 +19,18 @@ loop_control: label: "{{ item | basename }}" -- name: ROOT | set zsh for shell +- name: ROOT | ssh config + when: inventory_hostname not in groups.station become: no - ansible.builtin.user: - name: root - shell: /bin/zsh + ansible.builtin.template: + dest: "/root/.ssh/config" + src: templates/ssh-config.j2 + mode: 0640 + +- name: ROOT | local public key + become: no + ansible.builtin.authorized_key: + comment: "Managed by Ansible" + key: https://gitlab.com/free_zed.keys state: present + user: root diff --git a/tasks/user_cfg/templates/pruneconfig.j2 b/tasks/user_cfg/templates/pruneconfig.j2 index 3bfdb5db32e22e069f566da0eb05ec8d3b658668..ebe9855a316441bbd90dcf70063aa6ab66674c99 100644 --- a/tasks/user_cfg/templates/pruneconfig.j2 +++ b/tasks/user_cfg/templates/pruneconfig.j2 @@ -1,12 +1,6 @@ # ############################################# # -# GpsPrune config file # -# ~/.pruneconfig # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # prune.unitsetkey=unitset.kilometres diff --git a/tasks/user_cfg/templates/ssh_config.j2 b/tasks/user_cfg/templates/ssh_config.j2 index 05e7661dc76eec06b75f1defb0dd7394e83890b0..331ab2a606868abadfb281129da020ffda23ee9a 100644 --- a/tasks/user_cfg/templates/ssh_config.j2 +++ b/tasks/user_cfg/templates/ssh_config.j2 @@ -1,13 +1,7 @@ #jinja2:lstrip_blocks: True # ############################################# # -# SSH config file # -# ~/.ssh/config # -# # # This file is managed by Ansible # -# Manual edition will be overridden # -# # # https://lab.frogg.it/freezed/ansible-debian # -# # # ############################################# # {% for host in groups['all'] %} diff --git a/tasks/user_cfg/vars/git.yml b/tasks/user_cfg/vars/git.yml index b87733892e7e912032283951bb51da92b4cc27a7..4938798ba0d234c9931fbf12e8a4b82adea03be6 100644 --- a/tasks/user_cfg/vars/git.yml +++ b/tasks/user_cfg/vars/git.yml @@ -1,24 +1,19 @@ --- git_repositories: - - {local_name: "afpy19", url_https: "https://gitlab.com/free_zed/afpy19.git"} - {local_name: "askthom", url_https: "https://lab.frogg.it/fcode/askthom.git"} - - {local_name: "djlease", url_https: "https://gitlab.com/free_zed/djlease.git"} + - {local_name: "delarte", url_https: "https://git.afpy.org/fcode/delarte.git"} - {local_name: "eb-car", url_https: "https://gitlab.com/combien-de-temps-pour-faire-sonner-la-cloche-a-aiguebelle/combien-de-temps-pour-faire-sonner-la-cloche-a-aiguebelle.gitlab.io.git"} - - {local_name: "exchange", url_https: "https://gitlab.com/free_zed/mymsesb.git"} - {local_name: "forga-a14n", url_https: "https://gitlab.com/free_zed/djbp.git"} - {local_name: "forga-core", url_https: "https://gitlab.com/forga/tool/django/core.git"} - - {local_name: "forga-dev-bpy", url_https: "https://gitlab.com/forga/devel/boilerplate/python.git"} - - {local_name: "forga-emb", url_https: "https://gitlab.com/forga/process/fr/embarquement.git"} - - {local_name: "forga-glio", url_https: "https://gitlab.com/forga/forga.gitlab.io.git"} - - {local_name: "forga-man", url_https: "https://gitlab.com/forga/process/fr/manuel.git"} - - {local_name: "forga-tool-debian", url_https: "https://lab.frogg.it/fcode/ansible/debian.git"} + - {local_name: "forga-dev-bpy", url_https: "https://git.afpy.org/fcode/boilerplate-python.git"} + - {local_name: "forga-tool-debian", url_https: "https://lab.frogg.it/freezed/ansible-debian.git"} - {local_name: "freezed.gl.io", url_https: "https://gitlab.com/free_zed/free_zed.gitlab.io.git"} - {local_name: "ftalk-gitlab", url_https: "https://gitlab.com/ftalk/2020-gitlab.git"} + - {local_name: "ftalk-zfs", url_https: "https://gitlab.com/ftalk/openzfs.git"} - {local_name: "geostrapy", url_https: "https://lab.frogg.it/fcode/geostrapy.git"} - - {local_name: "gpxpy", url_https: "https://github.com/freezed/gpxpy.git"} - {local_name: "grandpy", url_https: "https://github.com/freezed/ocp7.git"} - {local_name: "hellozappa", url_https: "https://gitlab.com/free_zed/hellozappa.git"} - - {local_name: "men-rt-ocp08", url_https: "https://github.com/remace/OC-P8-Purbeurre.git"} + - {local_name: "ldpy", url_https: "https://git.afpy.org/fcode/LDPy.git"} - {local_name: "mountaingpx", url_https: "https://github.com/krisanselmo/mountaingpx.git"} - {local_name: "myasb", url_https: "https://gitlab.com/forga/tool/ansible/debian.git"} - {local_name: "mypsb", url_https: "https://gitlab.com/free_zed/mypsb.git"} diff --git a/tasks/vars/main.yml b/tasks/vars/main.yml index 38c6c2ae7e0ab2b8d31952e353141a64a2d62ae9..b265a5717c9704bc6046d9764f62c506c3b8aa69 100644 --- a/tasks/vars/main.yml +++ b/tasks/vars/main.yml @@ -1,27 +1,20 @@ --- base_pkg: - - detox - - git - htop - - iftop - - keychain - locales - lynx - progress - python3-apt - - python3-venv - rsync - screen - sudo - - tree + - tmux - unattended-upgrades - - unrar-free - unzip - vim - wget - xkcdpass - - xz-utils - zsh base_uninstall_pkg: @@ -37,6 +30,10 @@ base_uninstall_pkg: workstat_pkg: - ansible + - cheese + - easytag + - evolution + - evolution-plugins - geany-plugin-addons - geany-plugin-extrasel - geany-plugin-git-changebar @@ -49,14 +46,15 @@ workstat_pkg: - meld - mhwaveedit - pandoc + - python3-venv station_pkg: - cheese - evolution - evolution-plugins - flatpak - - gimp - git + - gimp - gnome-disk-utility - gnome-software-plugin-flatpak - gpsprune