diff --git a/install.sh b/install.sh index 8fbf440..82f1901 100755 --- a/install.sh +++ b/install.sh @@ -1,3 +1,3 @@ #!/bin/bash -ansible-playbook install.yml --extra-vars "lsb_release=$(lsb_release -cs)" --ask-become-pass +ansible-playbook install.yml --extra-vars "lsb_release=$(lsb_release -cs)" --ask-become-pass -i "localhost," -c local diff --git a/install.yml b/install.yml index c5d87ac..4750934 100644 --- a/install.yml +++ b/install.yml @@ -3,8 +3,7 @@ - hosts: localhost roles: - - common + #- common - back - - front vars_files: - - vars.yml \ No newline at end of file + - vars.yml diff --git a/roles/back/tasks/install_jdk_maven.yml b/roles/back/tasks/install_jdk_maven.yml new file mode 100644 index 0000000..b3f680c --- /dev/null +++ b/roles/back/tasks/install_jdk_maven.yml @@ -0,0 +1,23 @@ +- name: Create /home/{{ ansible_user }}/tmp directory + ansible.builtin.file: + path: /home/{{ ansible_user }}/tmp + state: directory + mode: '0755' + +- name: Download SDKMAN + get_url: + url: https://get.sdkman.io + dest: '/home/{{ ansible_user }}/tmp/sdkman_script' + owner: '{{ ansible_user }}' + group: '{{ ansible_user }}' + validate_certs: true + become: yes + +- name: Run sdkman script if /home/{{ ansible_user }}/.sdkman/bin/sdkman-init.sh does not exist + ansible.builtin.command: /bin/bash /home/{{ ansible_user }}/tmp/sdkman_script + args: + creates: /home/{{ ansible_user }}/.sdkman/bin/sdkman-init.sh + become: yes + +- name: Source sdkman + ansible.builtin.command: /bin/bash /home/{{ ansible_user }}/.sdkman/bin/sdkman-init.sh diff --git a/roles/back/tasks/main.yml b/roles/back/tasks/main.yml index 2fc2271..169db73 100644 --- a/roles/back/tasks/main.yml +++ b/roles/back/tasks/main.yml @@ -1,12 +1,2 @@ - -- name: Build home - import_tasks: home_building.yml - -- name: Install java - import_tasks: install_java.yml - -- name: Install gradle - import_tasks: install_gradle.yml - -- name: Install maven - import_tasks: install_maven.yml +- name: Install JDKs, maven + import_tasks: install_jdk_maven.yml diff --git a/roles/back/tasks/home_building.yml b/roles/back/tasks/old/home_building.yml similarity index 100% rename from roles/back/tasks/home_building.yml rename to roles/back/tasks/old/home_building.yml diff --git a/roles/back/tasks/install_gradle.yml b/roles/back/tasks/old/install_gradle.yml similarity index 100% rename from roles/back/tasks/install_gradle.yml rename to roles/back/tasks/old/install_gradle.yml diff --git a/roles/back/tasks/install_java.yml b/roles/back/tasks/old/install_java.yml similarity index 100% rename from roles/back/tasks/install_java.yml rename to roles/back/tasks/old/install_java.yml diff --git a/roles/back/tasks/install_maven.yml b/roles/back/tasks/old/install_maven.yml similarity index 100% rename from roles/back/tasks/install_maven.yml rename to roles/back/tasks/old/install_maven.yml diff --git a/roles/back/templates/.back_bash_aliases b/roles/back/templates/.back_bash_aliases index 78e702f..45f8f55 100644 --- a/roles/back/templates/.back_bash_aliases +++ b/roles/back/templates/.back_bash_aliases @@ -7,7 +7,6 @@ alias setjava7='export JAVA_HOME=/usr/lib/jvm/java-7-oracle' alias setjava8='export JAVA_HOME=/usr/lib/jvm/java-8-oracle' # maven -alias mvn='~/applications/maven/bin/mvn' alias mci='mvn clean install' alias mcis='mvn clean install -DskipTests' alias mct='mvn clean test' diff --git a/roles/common/tasks/minimal_tools.yml b/roles/common/tasks/core_tools.yml similarity index 60% rename from roles/common/tasks/minimal_tools.yml rename to roles/common/tasks/core_tools.yml index a2ae88f..efb2640 100644 --- a/roles/common/tasks/minimal_tools.yml +++ b/roles/common/tasks/core_tools.yml @@ -24,32 +24,26 @@ with_items: - build-essential - tmux + - curl - httpie - jq - git-flow - docker-ce + - zip - unzip - - vim-gtk + - vim - silversearcher-ag become: yes - name: Allow docker for non root command: groupadd -f docker become: yes -- user: name={{ansible_user}} groups=docker append=yes +- user: name={{ ansible_user }} groups=docker append=yes become: yes - -- name: Install docker-compose - get_url: - url: https://github.com/docker/compose/releases/download/{{ dc_version }}/docker-compose-{{ ansible_system }}-{{ ansible_userspace_architecture }} - dest: /usr/local/bin/docker-compose - mode: 0755 + +- name: Install docker compose plugin + apt: + name: docker-compose-plugin + install_recommends: yes become: yes -# Tmux -- name: Install tmux plugin manager - file: path=~/.tmux/plugins/tpm state=directory -- git: - repo: https://github.com/tmux-plugins/tpm - dest: ~/.tmux/plugins/tpm - update: no \ No newline at end of file diff --git a/roles/common/tasks/home_building.yml b/roles/common/tasks/home_building.yml index 7e9397c..24f63b7 100644 --- a/roles/common/tasks/home_building.yml +++ b/roles/common/tasks/home_building.yml @@ -6,7 +6,7 @@ - template: src=templates/.tmux.conf dest=~/.tmux.conf - template: src=templates/.bashrc dest=~/.bashrc mode=0755 - template: src=templates/.bash_aliases dest=~/.bash_aliases mode=0755 -- template: src=templates/.ssh/config dest=~/.ssh/config +#- template: src=templates/.ssh/config dest=~/.ssh/config - template: src=templates/git-repos-checkout-all.sh dest=~/bin/git-repos-checkout-all.sh mode=0755 - git: diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index de6d805..29f6961 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -1,7 +1,6 @@ - -- name: Build home +- name: Home building import_tasks: home_building.yml -- name: Install minimal tools - import_tasks: minimal_tools.yml - when: ansible_os_family == "Debian" \ No newline at end of file +- name: Install core tools (curl, jq, docker, docker compose) + import_tasks: core_tools.yml + when: ansible_os_family == "Debian" diff --git a/roles/common/templates/.bash_aliases b/roles/common/templates/.bash_aliases index 1695a40..af15f20 100644 --- a/roles/common/templates/.bash_aliases +++ b/roles/common/templates/.bash_aliases @@ -17,8 +17,6 @@ alias alais='alias' alias gitrepos_update_all='~/bin/git-repos-update-all.sh' alias gitrepos_checkout_all='~/bin/git-repos-checkout-all.sh' -alias ack='ack-grep' - alias gitbranchpurge='git fetch -p && git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1 git branch -d' alias gsubs='git pull && git submodule sync --recursive && git submodule update --init --recursive --jobs 8' diff --git a/roles/common/templates/.bashrc b/roles/common/templates/.bashrc index 51878dc..3f4eb2b 100644 --- a/roles/common/templates/.bashrc +++ b/roles/common/templates/.bashrc @@ -1,4 +1,3 @@ - #{{ ansible_managed }} if [ -n "$SSH_CLIENT" ]; then PS1="Via ssh: " @@ -10,41 +9,30 @@ case $- in *) return;; esac -. /etc/bash.bashrc - -# don't put duplicate lines in the history. See bash(1) for more options -# ... or force ignoredups and ignorespace -HISTCONTROL=ignoredups:ignorespace +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=10000 -HISTFILESIZE=100000 -export HISTTIMEFORMAT="%F %T" +HISTSIZE=1000 +HISTFILESIZE=2000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize -# Fix minor errors in directory name when cd'ing -shopt -s cdspell - -# Automatically enter a directory even when command is not prefixed with 'cd' -shopt -s autocd - -# When on, single tab is necessary instead of two to display the list of completions -bind 'set show-all-if-ambiguous on' - -# Disable suspend/resume process, aka flow control with ctrl+s/ctrl+q -stty -ixon +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # set variable identifying the chroot you work in (used in the prompt below) -if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi @@ -54,57 +42,101 @@ function display_profile { source ~/.bash-git-prompt/gitprompt.sh + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases alias ll='ls -alF' alias la='ls -A' -alias l='ls -l' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' -# enable ANSI color -export LESS="-r" +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). -if [ -f /etc/bash_completion ] && ! shopt -oq posix; then +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then . /etc/bash_completion + fi fi +[ -f ~/.fzf.bash ] && source ~/.fzf.bash + export TERM=xterm-256color export GDK_NATIVE_WINDOWS=1 -export JAVA_HOME=~/applications/jdk -export GRADLE_HOME=~/applications/gradle -export MAVEN_HOME=~/applications/maven -export CHROME_BIN=/usr/bin/chromium -export PATH=$PATH:$GRADLE_HOME/bin:$MAVEN_HOME/bin:$JAVA_HOME/bin export TZ='Europe/Paris' export LANG='en_US.UTF-8' export LANGUAGE='en_US.UTF-8' -export LC_ALL='en_US.UTF-8' - -if [ -f .environment ]; then - source .environment -fi - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi +#export LC_ALL='en_US.UTF-8' if [ -f ~/.back_bash_aliases ]; then . ~/.back_bash_aliases fi -if [ -f ~/.maven_bash_completion.bash ]; then - . ~/.maven_bash_completion.bash -fi - export FZF_DEFAULT_COMMAND='ag -g ""' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" @@ -120,4 +152,4 @@ function tmux { fi } -#{{ ansible_managed }} \ No newline at end of file +#{{ ansible_managed }} diff --git a/roles/common/templates/.tmux.conf b/roles/common/templates/.tmux.conf index 1447b20..2dd3fc0 100644 --- a/roles/common/templates/.tmux.conf +++ b/roles/common/templates/.tmux.conf @@ -18,7 +18,7 @@ set -g history-limit 100000 set -g status-right "#(docker ps -a -f id=`hostname` --format \"{{'{{.Names}}'}}\") #[bold]%d-%m-%Y#[nobold] %H:%M " set -g status-fg white set -g status-bg colour238 -setw -g window-status-current-bg blue +setw -g window-status-current-style bg=blue # number windows starting from 1 - handy for direct access set -g base-index 1 diff --git a/roles/front/tasks/install_node.yml b/roles/front/tasks/install_node.yml deleted file mode 100644 index 749650b..0000000 --- a/roles/front/tasks/install_node.yml +++ /dev/null @@ -1,22 +0,0 @@ - -- name: Install node {{ node_version }} - unarchive: - src: https://nodejs.org/dist/v{{ node_version }}/node-v{{ node_version }}-linux-x64.tar.gz - dest: ~/applications/ - remote_src: true - creates: ~/applications/node-v{{ node_version }}-linux-x64 -- file: state=link src=~/applications/node-v{{ node_version }}-linux-x64 dest=~/applications/node -- file: src=/home/{{ ansible_user }}/applications/node/bin/node dest=/usr/bin/node state=link - become: yes -- file: src=/home/{{ ansible_user }}/applications/node/bin/npm dest=/usr/bin/npm state=link - become: yes -- npm: global=true name=json state=latest -- npm: global=true name=lerna state=latest -- file: src=/home/{{ ansible_user }}/applications/node/bin/json dest=/usr/bin/json state=link - become: yes -- file: src=/home/{{ ansible_user }}/applications/node/bin/lerna dest=/usr/bin/lerna state=link - become: yes - -#clean -- file: path=~/applications/node-v{{ node_previous_version }}-linux-x64.tar.gz state=absent -- file: path=~/applications/node-v{{ node_previous_version }}-linux-x64 state=absent diff --git a/roles/front/tasks/install_yarn.yml b/roles/front/tasks/install_yarn.yml deleted file mode 100644 index 906f6a5..0000000 --- a/roles/front/tasks/install_yarn.yml +++ /dev/null @@ -1,21 +0,0 @@ -# yarn repo -- apt_key: - url: "https://dl.yarnpkg.com/debian/pubkey.gpg" - state: present - become: yes - -#clean -- file: path=/etc/apt/sources.list.d/yarn.list state=absent - -- apt_repository: - repo: deb http://dl.yarnpkg.com/debian/ stable main - state: present - filename: 'yarnpkg' - update_cache: yes - become: yes - -- apt: - name: yarn - state: latest - install_recommends: no - become: yes \ No newline at end of file diff --git a/roles/front/tasks/main.yml b/roles/front/tasks/main.yml deleted file mode 100644 index 90040b9..0000000 --- a/roles/front/tasks/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Install node - import_tasks: install_node.yml - -- name: Install yarn - import_tasks: install_yarn.yml - when: ansible_os_family == "Debian" \ No newline at end of file diff --git a/vars_example.yml b/vars_example.yml index 586f4a2..4e4546c 100644 --- a/vars_example.yml +++ b/vars_example.yml @@ -1,23 +1,15 @@ # Git user information -email: "augustin.gjini@gmail.com" -username: "Augustin Gjini" +email: "laurent.tonon@gmail.com" +username: "Laurent Tonon" # Java version -jdk: "java-se-8u40-ri" -jdk_url: "https://download.java.net/openjdk/jdk8u40/ri/jdk_ri-8u40-b25-linux-x64-10_feb_2015.tar.gz" -# oracle_jdk: "jdk-10.0.2" -# oracle_jdk_url: "http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz" - -gradle_version: "4.10.2" -maven_version: "3.5.4" +jdk17_version: "17.0.8-ms" +jdk21_version: "21.0.2-open" +maven_version: "3.9.4" # Docker compose dc_version: "1.22.0" -# Node js -node_previous_version: "8.9.4" -node_version: "10.2.1" - # A nexus repository (to be used in maven settings.xml) nexus_repository: "https://nexus.liveaction.com/repository/public/"