Added ansible lint CI step.

Cleanup and lint fixes
This commit is contained in:
Sagi Dayan 2022-01-18 11:19:19 +02:00
parent f41ce07bca
commit 8fcbb4cbdd
Signed by: sagi
GPG key ID: FAB96BFC63B46458
14 changed files with 111 additions and 42 deletions

View file

@ -1,10 +1,26 @@
--- ---
stages: stages:
- ansible lint
- x86 Systems - x86 Systems
Ansible Lint:
stage: ansible lint
image:
name: fedora:latest
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: Run Workstation playbook on fedora:
stage: x86 Systems stage: x86 Systems
image: fedora:latest image:
name: fedora:latest
script: script:
- dnf install -y ansible python3-pip - dnf install -y ansible python3-pip
- pip3 install -r ci-requirements.txt - pip3 install -r ci-requirements.txt
@ -16,14 +32,17 @@ Run Workstation playbook on fedora:
reports: reports:
junit: report.xml junit: report.xml
Run cli-tools playbook on centos: Run cli-tools playbook on centos stream 9:
stage: x86 Systems stage: x86 Systems
image: centos:latest image:
name: quay.io/centos/centos:stream9
script: 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 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 makecache
- dnf install -y ansible python3-pip - dnf install -y python3-pip
- pip3 install ansible
- pip3 install -r ci-requirements.txt - pip3 install -r ci-requirements.txt
- mkdir /tmp/artifacts - mkdir /tmp/artifacts
- ./run_play.sh cli-tools - ./run_play.sh cli-tools
@ -35,7 +54,8 @@ Run cli-tools playbook on centos:
Run Workstation playbook on ubuntu: Run Workstation playbook on ubuntu:
stage: x86 Systems stage: x86 Systems
image: ubuntu:latest image:
name: ubuntu:latest
script: script:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
- apt-get update - apt-get update
@ -44,7 +64,7 @@ Run Workstation playbook on ubuntu:
- apt-get install -y ansible python3-pip python3-apt - apt-get install -y ansible python3-pip python3-apt
- pip3 install -r ci-requirements.txt - pip3 install -r ci-requirements.txt
- mkdir /tmp/artifacts - mkdir /tmp/artifacts
- ./run_play.sh workstation - bash -c "./run_play.sh workstation"
- mv /tmp/artifacts/workstation-*.xml report.xml - mv /tmp/artifacts/workstation-*.xml report.xml
artifacts: artifacts:
when: always when: always
@ -53,13 +73,14 @@ Run Workstation playbook on ubuntu:
Run cli-tools playbook on debian: Run cli-tools playbook on debian:
stage: x86 Systems stage: x86 Systems
image: debian:latest image:
name: debian:latest
script: script:
- apt-get update - apt-get update
- apt-get install -y ansible python3-pip python3-apt - apt-get install -y ansible python3-pip python3-apt
- pip3 install -r ci-requirements.txt - pip3 install -r ci-requirements.txt
- mkdir /tmp/artifacts - mkdir /tmp/artifacts
- ./run_play.sh cli-tools - bash -c "./run_play.sh cli-tools"
- mv /tmp/artifacts/cli-tools-*.xml report.xml - mv /tmp/artifacts/cli-tools-*.xml report.xml
artifacts: artifacts:
when: always when: always

View file

@ -4,16 +4,16 @@
######################################################## ########################################################
# Get docs fast # Get docs fast
selected=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse` SELECTED=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse`
if [[ -z $selected ]]; then if [[ -z $SELECTED ]]; then
exit 0 exit 0
fi fi
read -p "What you want to know?: " query read -p "🏳️ What do you want to know about ${SELECTED}?: " query
query=`echo $query | tr ' ' '+'` query=`echo $query | tr ' ' '+'`
if [[ $selected == "TLDR" ]]; then if [[ $SELECTED == "TLDR" ]]; then
tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${selected} | Query: ${query}'" tmux neww -n "[🏳️ Cheat: ${SELECTED}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${SELECTED} | Query: ${query}'"
else 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 fi

View file

@ -38,6 +38,27 @@ export EDITOR=vim;
# Shell functions # 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() { function pre_check_tmux_for_layout() {
ERROR_PREFIX="[ERROR]: " ERROR_PREFIX="[ERROR]: "
@ -70,20 +91,8 @@ function ide() {
IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]" IDE_NAME="[⌨️ IDE: ${1:=$CURRENT_DIR}]"
pre_check_tmux_for_layout "ide" || return 1 pre_check_tmux_for_layout "ide" || return 1
clear;
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \ huh "${IDE_NAME}";
echo "${IDE_NAME}"; \
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-="; \
echo;echo Status:; \
echo -=-=-=-; \
git status; \
echo; \
echo Remotes:; \
echo -=-=-=-=; \
git remote -v | cat; \
echo;echo Files:; \
echo -=-=-=; \
ls -l
tmux split-window -h -p 80 tmux split-window -h -p 80
tmux split-window -h -p 30 tmux split-window -h -p 30
tmux send-keys "gitui" C-m tmux send-keys "gitui" C-m

View file

@ -35,7 +35,7 @@ bind-key j send-keys Down
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded." bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
# Lookup the cheat sheet <prefix>-i # Lookup the cheat sheet <prefix>-i
bind-key i run-shell "tmux neww ~/.shellconfig/cheat.sh" bind-key i run-shell "tmux neww -n '🏳️ CHEATER\! 😎' ~/.shellconfig/cheat.sh"
############################ ############################
# Themes # Themes
########################### ###########################

6
install-ansible-modules.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
echo "===> Installing Ansible Dependencies"
ansible-galaxy collection install community.general
ansible-galaxy install hurricanehrndz.rustup

View file

@ -10,16 +10,19 @@
become: true become: true
package: package:
name: alacritty name: alacritty
state: latest state: present
- name: Setting up alacritty config file - name: Setting up alacritty config file
copy: copy:
src: dotfiles/alacritty.yml src: dotfiles/alacritty.yml
dest: ~/.alacritty.yml dest: ~/.alacritty.yml
mode: preserve
changed_when: false
- name: "Setting Alacritty theme" - name: "Setting Alacritty theme"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.alacritty.yml" path: "~/.alacritty.yml"
regexp: "^colors:" regexp: "^colors:"
line: "colors: *{{theme}}" line: "colors: *{{ theme }}"
changed_when: false

View file

@ -10,6 +10,7 @@
- git - git
- ranger - ranger
- jq - jq
- fzf
- man-db - man-db
state: present state: present
@ -25,11 +26,14 @@
src: dotfiles/gitconfig src: dotfiles/gitconfig
dest: ~/.gitconfig dest: ~/.gitconfig
force: no force: no
mode: preserve
- name: Setting up oh-my-zsh - name: Setting up oh-my-zsh
git: git:
repo: https://github.com/ohmyzsh/ohmyzsh.git repo: https://github.com/ohmyzsh/ohmyzsh.git
dest: ~/.oh-my-zsh dest: ~/.oh-my-zsh
version: master
- name: Making sure to use ZSH as shell - name: Making sure to use ZSH as shell
become: true become: true
@ -42,17 +46,20 @@
src: dotfiles/zshrc src: dotfiles/zshrc
dest: ~/.zshrc dest: ~/.zshrc
force: yes force: yes
mode: preserve
- name: Add ranger devicons plugin repo - name: Add ranger devicons plugin repo
git: git:
repo: https://github.com/alexanderjeurissen/ranger_devicons.git repo: https://github.com/alexanderjeurissen/ranger_devicons.git
dest: ~/.config/ranger/plugins/ranger_devicons dest: ~/.config/ranger/plugins/ranger_devicons
version: main
- name: Validate ranger config file - name: Validate ranger config file
changed_when: false changed_when: false
file: file:
path: ~/.config/ranger/rc.conf path: ~/.config/ranger/rc.conf
state: touch state: touch
mode: u=rw,g=r,o=r
- name: Activate ranger devicons plugin - name: Activate ranger devicons plugin
lineinfile: lineinfile:
@ -64,16 +71,19 @@
file: file:
path: ~/.shellconfig path: ~/.shellconfig
state: directory state: directory
mode: '0755'
- name: Verifying shell autocomplete config folder - name: Verifying shell autocomplete config folder
file: file:
path: ~/.shellconfig/autocomplete path: ~/.shellconfig/autocomplete
state: directory state: directory
mode: '0755'
- name: Verifying shell cheat config folder - name: Verifying shell cheat config folder
file: file:
path: ~/.shellconfig/cheat path: ~/.shellconfig/cheat
state: directory state: directory
mode: '0755'
- name: Sync Common shell settings... - name: Sync Common shell settings...
changed_when: false changed_when: false
@ -81,6 +91,7 @@
src: dotfiles/shellconfig/common.sh src: dotfiles/shellconfig/common.sh
dest: ~/.shellconfig/common.sh dest: ~/.shellconfig/common.sh
force: yes force: yes
mode: preserve
- name: Sync Cheat script - name: Sync Cheat script
changed_when: false changed_when: false
@ -95,24 +106,28 @@
src: dotfiles/shellconfig/aliases.sh src: dotfiles/shellconfig/aliases.sh
dest: ~/.shellconfig/aliases.sh dest: ~/.shellconfig/aliases.sh
force: no force: no
mode: preserve
- name: Copy shell functions - name: Copy shell functions
copy: copy:
src: dotfiles/shellconfig/functions.sh src: dotfiles/shellconfig/functions.sh
dest: ~/.shellconfig/functions.sh dest: ~/.shellconfig/functions.sh
force: no force: no
mode: preserve
- name: Copy shell environment - name: Copy shell environment
copy: copy:
src: dotfiles/shellconfig/environment.sh src: dotfiles/shellconfig/environment.sh
dest: ~/.shellconfig/environment.sh dest: ~/.shellconfig/environment.sh
force: no force: no
mode: preserve
- name: Copy topics cheat sheet list - name: Copy topics cheat sheet list
copy: copy:
src: dotfiles/shellconfig/cheat/topics src: dotfiles/shellconfig/cheat/topics
dest: ~/.shellconfig/cheat/topics dest: ~/.shellconfig/cheat/topics
force: yes force: yes
mode: preserve
- name: Install modern UNIX tools - name: Install modern UNIX tools
include_role: include_role:

View file

@ -33,6 +33,7 @@
- name: Check if open function is set - name: Check if open function is set
shell: grep -c "^function open" ~/.shellconfig/functions.sh || true shell: grep -c "^function open" ~/.shellconfig/functions.sh || true
register: open_test register: open_test
changed_when: false
- name: "Adding 'open' shell function" - name: "Adding 'open' shell function"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:

View file

@ -5,6 +5,8 @@
state: directory state: directory
owner: root owner: root
group: root group: root
mode: '0755'
changed_when: false
- name: Installing Hack Nerd Font - name: Installing Hack Nerd Font
become: true become: true
@ -13,3 +15,4 @@
dest: /usr/share/fonts/hack/hack_nerd_font.ttf dest: /usr/share/fonts/hack/hack_nerd_font.ttf
owner: root owner: root
group: root group: root
mode: preserve

View file

@ -3,6 +3,7 @@
ansible.builtin.file: ansible.builtin.file:
state: directory state: directory
path: ~/.ansible_gh_release_versions path: ~/.ansible_gh_release_versions
mode: '0755'
- name: Setting local release file path - name: Setting local release file path
set_fact: set_fact:
@ -16,7 +17,8 @@
changed_when: false changed_when: false
- name: Get latest version tag from github - name: Get latest version tag from github
shell: echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)" shell:
cmd: 'echo {{ tar_url.stdout }} | grep -oP "(?<=download\/).*(?=\/)"'
changed_when: false changed_when: false
register: version register: version
@ -50,7 +52,7 @@
- name: Update mandb if needed - name: Update mandb if needed
become: true become: true
shell: mandb shell: mandb || true
when: added_man is defined and (version != local_version) when: added_man is defined and (version != local_version)
- name: Adding autocomplete if needed - name: Adding autocomplete if needed

View file

@ -15,10 +15,12 @@
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.shellconfig/common.sh" path: "~/.shellconfig/common.sh"
regexp: "^export BAT_THEME=" regexp: "^export BAT_THEME="
line: 'export BAT_THEME="${{theme}}"' line: 'export BAT_THEME="${{ theme }}"'
- name: Instaling TLDR (pip3) - name: Instaling TLDR (pip3)
shell: pip3 install tldr become: true
shell: pip3 install tldr || true
changed_when: false
- name: Installing bottom (btm) (Top like) - name: Installing bottom (btm) (Top like)
ansible.builtin.include_role: ansible.builtin.include_role:
@ -43,18 +45,21 @@
file: file:
path: ~/.config/gitui path: ~/.config/gitui
state: directory state: directory
mode: '0755'
- name: Copy gitui keybindings - name: Copy gitui keybindings
copy: copy:
src: dotfiles/gitui/key_config.ron src: dotfiles/gitui/key_config.ron
dest: ~/.config/gitui/key_config.ron dest: ~/.config/gitui/key_config.ron
force: yes force: yes
mode: preserve
- name: Copy gitui theme config - name: Copy gitui theme config
copy: copy:
src: dotfiles/gitui/theme.ron src: dotfiles/gitui/theme.ron
dest: ~/.config/gitui/theme.ron dest: ~/.config/gitui/theme.ron
force: yes force: yes
mode: preserve
- name: Installing LSD (ls like) - name: Installing LSD (ls like)
ansible.builtin.include_role: ansible.builtin.include_role:

View file

@ -2,15 +2,17 @@
become: true become: true
package: package:
name: tmux name: tmux
state: latest state: present
- name: Install tmux plugin manager - name: Install tmux plugin manager
git: git:
repo: https://github.com/tmux-plugins/tpm repo: https://github.com/tmux-plugins/tpm
dest: ~/.tmux/plugins/tpm dest: ~/.tmux/plugins/tpm
update: yes update: yes
version: master
- name: Copy tmux config file - name: Copy tmux config file
copy: copy:
src: dotfiles/tmux.conf src: dotfiles/tmux.conf
dest: ~/.tmux.conf dest: ~/.tmux.conf
mode: preserve

View file

@ -4,7 +4,7 @@
name: name:
- vim-X11 - vim-X11
- the_silver_searcher - the_silver_searcher
state: latest state: present
when: ansible_facts['os_family'] == "RedHat" when: ansible_facts['os_family'] == "RedHat"
- name: Install vim (Debian based) - name: Install vim (Debian based)
@ -20,6 +20,7 @@
file: file:
path: ~/.vim/autoload path: ~/.vim/autoload
state: directory state: directory
mode: '0755'
- name: Install vim Plug - name: Install vim Plug
get_url: get_url:
@ -30,12 +31,15 @@
copy: copy:
src: dotfiles/vimrc src: dotfiles/vimrc
dest: "~/.vimrc" dest: "~/.vimrc"
mode: preserve
changed_when: false
- name: "Set vim colorscheme" - name: "Set vim colorscheme"
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "~/.vimrc" path: "~/.vimrc"
regexp: "^colorscheme" regexp: "^colorscheme"
line: "colorscheme base16-{{theme}}" line: "colorscheme base16-{{ theme }}"
changed_when: false
#- name: "Set vim lightline colorscheme" #- name: "Set vim lightline colorscheme"
# ansible.builtin.lineinfile: # ansible.builtin.lineinfile:

View file

@ -16,9 +16,7 @@ function print_fail_and_exit() {
echo "======> Running ${TARGET_PLAY}" echo "======> Running ${TARGET_PLAY}"
# Install Dependencies ./install-ansible-modules.sh
ansible-galaxy collection install community.general
ansible-galaxy install hurricanehrndz.rustup
# Run Playbook # Run Playbook
ANSIBLE_CONFIG=$(pwd)/ansible.cfg JUNIT_OUTPUT_DIR="/tmp/artifacts" ansible-playbook ${PLAYBOOK} || print_fail_and_exit ANSIBLE_CONFIG=$(pwd)/ansible.cfg JUNIT_OUTPUT_DIR="/tmp/artifacts" ansible-playbook ${PLAYBOOK} || print_fail_and_exit