diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58a8a11..d5769cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,28 @@ --- stages: +- ansible lint - x86 Systems +Ansible Lint: + stage: ansible lint + image: + name: fedora:latest + entrypoint: ["/bin/bash", "-c"] + before_script: + - dnf install -y git ansible python3-ansible-lint + - export ANSIBLE_CONFIG=$(pwd)/ansible.cfg + - ./install-ansible-modules.sh + - ansible-lint --version + script: + - ansible-lint --force-color . &> lint-output.txt + - cat lint-output.txt + - if [ ! -z "$(cat lint-output.txt)" ]; then echo "Lint returned with warnings/fails"; exit 1; fi + Run Workstation playbook on fedora: stage: x86 Systems - image: fedora:latest + image: + name: fedora:latest + entrypoint: ["/bin/bash", "-c"] script: - dnf install -y ansible python3-pip - pip3 install -r ci-requirements.txt @@ -16,11 +34,14 @@ Run Workstation playbook on fedora: reports: junit: report.xml -Run cli-tools playbook on centos: +Run cli-tools playbook on centos stream 9: stage: x86 Systems - image: centos:latest + image: + name: quay.io/centos/centos:stream9 + entrypoint: ["/bin/bash", "-c"] script: - - dnf install -y epel-release dnf-plugins-core + - dnf install -y dnf-plugins-core + - dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm - dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm - dnf makecache - dnf install -y ansible python3-pip @@ -35,7 +56,9 @@ Run cli-tools playbook on centos: Run Workstation playbook on ubuntu: stage: x86 Systems - image: ubuntu:latest + image: + name: ubuntu:latest + entrypoint: ["/bin/bash", "-c"] script: - export DEBIAN_FRONTEND=noninteractive - apt-get update @@ -53,7 +76,9 @@ Run Workstation playbook on ubuntu: Run cli-tools playbook on debian: stage: x86 Systems - image: debian:latest + image: + name: debian:latest + entrypoint: ["/bin/bash", "-c"] script: - apt-get update - apt-get install -y ansible python3-pip python3-apt diff --git a/files/dotfiles/shellconfig/cheat.sh b/files/dotfiles/shellconfig/cheat.sh index ec0d79c..776ce38 100755 --- a/files/dotfiles/shellconfig/cheat.sh +++ b/files/dotfiles/shellconfig/cheat.sh @@ -4,16 +4,16 @@ ######################################################## # Get docs fast -selected=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse` -if [[ -z $selected ]]; then +SELECTED=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse` +if [[ -z $SELECTED ]]; then exit 0 fi -read -p "What you want to know?: " query +read -p "🏳️ What do you want to know about ${SELECTED}?: " query query=`echo $query | tr ' ' '+'` -if [[ $selected == "TLDR" ]]; then - tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${selected} | Query: ${query}'" +if [[ $SELECTED == "TLDR" ]]; then + tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${SELECTED} | Query: ${query}'" else - tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "curl -s https://cht.sh/$selected/$query | bat --paging=always --file-name='Topic: ${selected} | Query: ${query}'" + tmux neww -n "[🏳️ Cheat: ${SELECTED}/${query}]" bash -c "curl -s https://cht.sh/$SELECTED/$query | bat --paging=always --file-name='Topic: ${SELECTED} | Query: ${query}'" fi diff --git a/files/dotfiles/shellconfig/common.sh b/files/dotfiles/shellconfig/common.sh index c4111f7..a96c975 100644 --- a/files/dotfiles/shellconfig/common.sh +++ b/files/dotfiles/shellconfig/common.sh @@ -38,6 +38,27 @@ export EDITOR=vim; # Shell functions ############################################ +function huh() { + CURRENT_DIR=$(echo "${PWD##*/}") + TITLE="${1:=$CURRENT_DIR}" + + echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ + echo "${TITLE}"; \ + echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ + echo;echo Status:; \ + echo -=-=-=-; \ + git status; \ + echo; \ + echo Remotes:; \ + echo -=-=-=-=; \ + git remote -v | cat; \ + echo;echo Files:; \ + echo -=-=-=; \ + ls -l; \ + echo;echo; + +} + function pre_check_tmux_for_layout() { ERROR_PREFIX="[ERROR]: " @@ -70,20 +91,8 @@ function ide() { IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]" pre_check_tmux_for_layout "ide" || return 1 - - echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ - echo "${IDE_NAME}"; \ - echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ - echo;echo Status:; \ - echo -=-=-=-; \ - git status; \ - echo; \ - echo Remotes:; \ - echo -=-=-=-=; \ - git remote -v | cat; \ - echo;echo Files:; \ - echo -=-=-=; \ - ls -l + clear; + huh "${IDE_NAME}"; tmux split-window -h -p 80 tmux split-window -h -p 30 tmux send-keys "gitui" C-m diff --git a/files/dotfiles/tmux.conf b/files/dotfiles/tmux.conf index 4616dac..c39a811 100644 --- a/files/dotfiles/tmux.conf +++ b/files/dotfiles/tmux.conf @@ -35,7 +35,7 @@ bind-key j send-keys Down bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded." # Lookup the cheat sheet -i -bind-key i run-shell "tmux neww ~/.shellconfig/cheat.sh" +bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat.sh" ############################ # Themes ########################### diff --git a/install-ansible-modules.sh b/install-ansible-modules.sh new file mode 100755 index 0000000..b2364e2 --- /dev/null +++ b/install-ansible-modules.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "===> Installing Ansible Dependencies" +ansible-galaxy collection install community.general +ansible-galaxy install hurricanehrndz.rustup + diff --git a/roles/alacritty_user/tasks/main.yml b/roles/alacritty_user/tasks/main.yml index 062532e..4b63521 100644 --- a/roles/alacritty_user/tasks/main.yml +++ b/roles/alacritty_user/tasks/main.yml @@ -10,16 +10,19 @@ become: true package: name: alacritty - state: latest + state: present - name: Setting up alacritty config file copy: src: dotfiles/alacritty.yml dest: ~/.alacritty.yml + mode: preserve + changed_when: false - name: "Setting Alacritty theme" ansible.builtin.lineinfile: path: "~/.alacritty.yml" regexp: "^colors:" - line: "colors: *{{theme}}" + line: "colors: *{{ theme }}" + changed_when: false diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index f085d11..0ba8961 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -10,6 +10,7 @@ - git - ranger - jq + - fzf - man-db state: present @@ -25,11 +26,14 @@ src: dotfiles/gitconfig dest: ~/.gitconfig force: no + mode: preserve - name: Setting up oh-my-zsh git: repo: https://github.com/ohmyzsh/ohmyzsh.git dest: ~/.oh-my-zsh + version: master + - name: Making sure to use ZSH as shell become: true @@ -42,17 +46,20 @@ src: dotfiles/zshrc dest: ~/.zshrc force: yes + mode: preserve - name: Add ranger devicons plugin repo git: repo: https://github.com/alexanderjeurissen/ranger_devicons.git dest: ~/.config/ranger/plugins/ranger_devicons + version: main - name: Validate ranger config file changed_when: false file: path: ~/.config/ranger/rc.conf state: touch + mode: u=rw,g=r,o=r - name: Activate ranger devicons plugin lineinfile: @@ -64,16 +71,19 @@ file: path: ~/.shellconfig state: directory + mode: '0755' - name: Verifying shell autocomplete config folder file: path: ~/.shellconfig/autocomplete state: directory + mode: '0755' - name: Verifying shell cheat config folder file: path: ~/.shellconfig/cheat state: directory + mode: '0755' - name: Sync Common shell settings... changed_when: false @@ -81,6 +91,7 @@ src: dotfiles/shellconfig/common.sh dest: ~/.shellconfig/common.sh force: yes + mode: preserve - name: Sync Cheat script changed_when: false @@ -95,24 +106,28 @@ src: dotfiles/shellconfig/aliases.sh dest: ~/.shellconfig/aliases.sh force: no + mode: preserve - name: Copy shell functions copy: src: dotfiles/shellconfig/functions.sh dest: ~/.shellconfig/functions.sh force: no + mode: preserve - name: Copy shell environment copy: src: dotfiles/shellconfig/environment.sh dest: ~/.shellconfig/environment.sh force: no + mode: preserve - name: Copy topics cheat sheet list copy: src: dotfiles/shellconfig/cheat/topics dest: ~/.shellconfig/cheat/topics force: yes + mode: preserve - name: Install modern UNIX tools include_role: diff --git a/roles/flatpaks/tasks/main.yml b/roles/flatpaks/tasks/main.yml index f3fdef3..01c142e 100644 --- a/roles/flatpaks/tasks/main.yml +++ b/roles/flatpaks/tasks/main.yml @@ -33,6 +33,7 @@ - name: Check if open function is set shell: grep -c "^function open" ~/.shellconfig/functions.sh || true register: open_test + changed_when: false - name: "Adding 'open' shell function" ansible.builtin.lineinfile: diff --git a/roles/fonts/tasks/main.yml b/roles/fonts/tasks/main.yml index 271a9ab..fefae5a 100644 --- a/roles/fonts/tasks/main.yml +++ b/roles/fonts/tasks/main.yml @@ -5,6 +5,8 @@ state: directory owner: root group: root + mode: u=rw,g=r,o=r + changed_when: false - name: Installing Hack Nerd Font become: true @@ -13,3 +15,4 @@ dest: /usr/share/fonts/hack/hack_nerd_font.ttf owner: root group: root + mode: preserve diff --git a/roles/gh_release_bin/tasks/main.yml b/roles/gh_release_bin/tasks/main.yml index 0134d2f..10e224e 100644 --- a/roles/gh_release_bin/tasks/main.yml +++ b/roles/gh_release_bin/tasks/main.yml @@ -3,6 +3,7 @@ ansible.builtin.file: state: directory path: ~/.ansible_gh_release_versions + mode: '0755' - name: Setting local release file path set_fact: @@ -16,7 +17,7 @@ changed_when: false - name: Get latest version tag from github - shell: echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)" + shell: 'set -o pipefail && echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)"' changed_when: false register: version @@ -50,7 +51,7 @@ - name: Update mandb if needed become: true - shell: mandb + shell: mandb || true when: added_man is defined and (version != local_version) - name: Adding autocomplete if needed diff --git a/roles/modern_unix_tools/tasks/main.yml b/roles/modern_unix_tools/tasks/main.yml index e3d1c0e..93ca33d 100644 --- a/roles/modern_unix_tools/tasks/main.yml +++ b/roles/modern_unix_tools/tasks/main.yml @@ -15,10 +15,12 @@ ansible.builtin.lineinfile: path: "~/.shellconfig/common.sh" regexp: "^export BAT_THEME=" - line: 'export BAT_THEME="${{theme}}"' + line: 'export BAT_THEME="${{ theme }}"' - name: Instaling TLDR (pip3) - shell: pip3 install tldr + become: true + shell: pip3 install tldr || true + changed_when: false - name: Installing bottom (btm) (Top like) ansible.builtin.include_role: @@ -43,18 +45,21 @@ file: path: ~/.config/gitui state: directory + mode: '0755' - name: Copy gitui keybindings copy: src: dotfiles/gitui/key_config.ron dest: ~/.config/gitui/key_config.ron force: yes + mode: preserve - name: Copy gitui theme config copy: src: dotfiles/gitui/theme.ron dest: ~/.config/gitui/theme.ron force: yes + mode: preserve - name: Installing LSD (ls like) ansible.builtin.include_role: diff --git a/roles/tmux_user/tasks/main.yml b/roles/tmux_user/tasks/main.yml index ed6137d..6319fcd 100644 --- a/roles/tmux_user/tasks/main.yml +++ b/roles/tmux_user/tasks/main.yml @@ -2,15 +2,17 @@ become: true package: name: tmux - state: latest + state: present - name: Install tmux plugin manager git: repo: https://github.com/tmux-plugins/tpm dest: ~/.tmux/plugins/tpm update: yes + version: master - name: Copy tmux config file copy: src: dotfiles/tmux.conf dest: ~/.tmux.conf + mode: preserve diff --git a/roles/vim_user/tasks/main.yml b/roles/vim_user/tasks/main.yml index f60833f..c5a388f 100644 --- a/roles/vim_user/tasks/main.yml +++ b/roles/vim_user/tasks/main.yml @@ -4,7 +4,7 @@ name: - vim-X11 - the_silver_searcher - state: latest + state: present when: ansible_facts['os_family'] == "RedHat" - name: Install vim (Debian based) @@ -20,6 +20,7 @@ file: path: ~/.vim/autoload state: directory + mode: '0755' - name: Install vim Plug get_url: @@ -30,12 +31,15 @@ copy: src: dotfiles/vimrc dest: "~/.vimrc" + mode: preserve + changed_when: false - name: "Set vim colorscheme" ansible.builtin.lineinfile: path: "~/.vimrc" regexp: "^colorscheme" - line: "colorscheme base16-{{theme}}" + line: "colorscheme base16-{{ theme }}" + changed_when: false #- name: "Set vim lightline colorscheme" # ansible.builtin.lineinfile: diff --git a/run_play.sh b/run_play.sh index 5b26f68..895f572 100755 --- a/run_play.sh +++ b/run_play.sh @@ -16,9 +16,7 @@ function print_fail_and_exit() { echo "======> Running ${TARGET_PLAY}" -# Install Dependencies -ansible-galaxy collection install community.general -ansible-galaxy install hurricanehrndz.rustup +./install-ansible-modules.sh # Run Playbook ANSIBLE_CONFIG=$(pwd)/ansible.cfg JUNIT_OUTPUT_DIR="/tmp/artifacts" ansible-playbook ${PLAYBOOK} || print_fail_and_exit