From 247f6cccb6cae00d4e4cfb85ade1157d13e87d35 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Thu, 16 Jan 2020 10:46:42 +0100 Subject: [PATCH] [BREAKING] use configureable gitconfig file --- README.md | 27 +++++++++++++++++---------- tasks/usersettings.yml | 8 +++----- templates/_gitconfig.j2 | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 templates/_gitconfig.j2 diff --git a/README.md b/README.md index eff6e19..65e33d5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ This role is compatible with Debian based systems and macOS. Requirements ------------ -none +Have a user set up on the machine, to which you can connecto via a ssh key. +This user must also have sudo right without asking for a password! +(e.g. using `%sudo ALL=(ALL) NOPASSWD:ALL` when editing the sudoers file with `sudo visudo`) Role Variables @@ -19,18 +21,23 @@ But for some operating systems the `ansible_os_family` variable is not set to "D - `override_os_family`: Set to "Debian" in the host inventory, if `ansible_os_family` is not set correctly The User Setup will change the user shell and global gitconfig. This can be disabled: -- `usersetup_chsh`: Boolean to disable changing the user shell to zsh -- `usersetup_gitconfig`: Boolean to disable overriding the global gitconfig +- `usersetup_chsh`: Boolean to enable changing the user shell to zsh (default: true) +- `usersetup_gitconfig`: Boolean to disable overriding the global gitconfig (default: true) + * `gitconfig_name`: User's name in .gitconfig file (default: n.a.) + * `gitconfig_email`: User's email in .gitconfig file (default: n.a.) +The development environment for different programming languages can be setup automatically. +To enable, that Visual Studio Code will be installed and configured, set `user_vscode` to true, otherwise only the bare development toolchain will be installed. For a GUI/ Desktop machine, you can enable to install and configure VS Code: -- `user_vscode`: Boolean to install and set the basic configuration of VS Code -- `user_lang_cpp`: Boolean to install C/C++ dev tools and configure VS Code -- `user_lang_python`: Boolean to install Python dev tools and configure VS Code -- `user_lang_golang`: Boolean to install Golang dev tools and configure VS Code +- `user_vscode`: Boolean to install and set the basic configuration of VS Code (default: false) +- `user_lang_cpp`: Boolean to install C/C++ dev tools and configure VS Code (default: false) +- `user_lang_python`: Boolean to install Python dev tools and configure VS Code (default: false) +- `user_lang_golang`: Boolean to install Golang dev tools and configure VS Code (default: false) + * `user_lang_golang_gopath`: Install path for golang (default: "{{ ansible_user_dir }}/Development/go") -The `user_lang_*` switches will also install the language only, if `user_vscode` is set to false. - -To install just the dotfiles, set `common_settingsonly` to true. +By default, this role will run updates, install some essential tools, set up the user's shell and copy the dotfiles. +If you just want to have the dotfiles managed by ansible, set `common_settingsonly` to true! +This can be useful, if you have no sudo rights, because tool installation will need these. Dependencies diff --git a/tasks/usersettings.yml b/tasks/usersettings.yml index 9ba4f77..a39a605 100644 --- a/tasks/usersettings.yml +++ b/tasks/usersettings.yml @@ -28,11 +28,9 @@ - { src: "{{ role_path }}/files/dotfiles/_oh-my-zsh/custom/themes/agnoster.zsh-theme", dest: ".oh-my-zsh/custom/themes/agnoster.zsh-theme" } - { src: "{{ role_path }}/files/dotfiles/_oh-my-zsh/custom/themes/jtbx.zsh-theme", dest: ".oh-my-zsh/custom/themes/jtbx.zsh-theme" } - name: usersettings - Set global gitconfig - copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: "{{ role_path }}/files/dotfiles/_gitconfig", dest: ".gitconfig" } + template: + src: "{{ role_path }}/templates/_gitconfig.j2" + dest: "{{ ansible_user_dir }}/.gitconfig" when: usersetup_gitconfig == true - name: usersettings - Create .vim directory diff --git a/templates/_gitconfig.j2 b/templates/_gitconfig.j2 new file mode 100644 index 0000000..c06dd7d --- /dev/null +++ b/templates/_gitconfig.j2 @@ -0,0 +1,14 @@ +{% if gitconfig_name is defined and gitconfig_email is defined %} +[user] + name = {{ gitconfig_name }} + email = {{ gitconfig_email }} +{% endif %} +[core] + excludesfile = ~/.gitignore_global + editor = vi +[push] + default = matching +[color] + ui = auto +[help] + autocorrect = 1