Merge branch 'cleanups' into 'main'

Added ansible lint CI step.

See merge request sagidayan/linux-config!9
This commit is contained in:
Sagi Dayan 2022-01-19 15:30:13 +00:00
commit 443f4b1c5e
14 changed files with 123 additions and 39 deletions

View file

@ -1,10 +1,26 @@
---
stages:
- ansible lint
- 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:
stage: x86 Systems
image: fedora:latest
image:
name: fedora:latest
script:
- dnf install -y ansible python3-pip
- pip3 install -r ci-requirements.txt
@ -18,7 +34,8 @@ Run Workstation playbook on fedora:
Run cli-tools playbook on centos:
stage: x86 Systems
image: centos:latest
image:
name: centos:latest
script:
- dnf install -y epel-release dnf-plugins-core
- 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
@ -35,7 +52,8 @@ Run cli-tools playbook on centos:
Run Workstation playbook on ubuntu:
stage: x86 Systems
image: ubuntu:latest
image:
name: ubuntu:latest
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
@ -53,7 +71,8 @@ Run Workstation playbook on ubuntu:
Run cli-tools playbook on debian:
stage: x86 Systems
image: debian:latest
image:
name: debian:latest
script:
- apt-get update
- apt-get install -y ansible python3-pip python3-apt

View file

@ -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

View file

@ -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

View file

@ -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 <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
###########################

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
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 }}"
changed_when: false

View file

@ -25,11 +25,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 +45,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 +70,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 +90,7 @@
src: dotfiles/shellconfig/common.sh
dest: ~/.shellconfig/common.sh
force: yes
mode: preserve
- name: Sync Cheat script
changed_when: false
@ -95,24 +105,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:

View file

@ -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:

View file

@ -5,6 +5,8 @@
state: directory
owner: root
group: root
mode: '0755'
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

View file

@ -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,8 @@
changed_when: false
- 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
register: version
@ -35,6 +37,13 @@
remote_src: yes
when: version != local_version
- name: Unarchive release source
ansible.builtin.unarchive:
src: "https://github.com/{{ repo }}/archive/refs/tags/{{ version }}.tar.gz"
dest: /tmp/
remote_src: yes
when: version != local_version and (include_source is defined)
- name: Moving bin to /usr/local/bin
become: true
shell: |
@ -50,12 +59,12 @@
- 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
shell: |
cp /tmp/{{ autocomplete_path }} ~/.shellconfig/autocomplete/
cp /tmp/{{ autocomplete_path }} ~/.shellconfig/autocomplete/{{ name }}.autocomplete
when: autocomplete_path is defined and (version != local_version)
- name: Updating local version entry

View file

@ -1,4 +1,16 @@
---
- name: Installing fzf
ansible.builtin.include_role:
name: gh_release_bin
vars:
name: fzf
repo: junegunn/fzf
bin_path: "/fzf"
autocomplete_path: "/fzf-*/shell/completion.zsh"
man_path: "/fzf-*/man/man1/fzf.1"
include_source: yes
filter: linux_amd64.tar.gz
- name: Installing bat (cat like)
ansible.builtin.include_role:
name: gh_release_bin
@ -7,7 +19,6 @@
repo: sharkdp/bat
bin_path: "/bat-*/bat"
man_path: "/bat-*/bat.1"
autocomplete_path: "/bat-*/autocomplete/bat.bash"
filter: x86_64-unknown-linux-gnu
- name: verify Bat (better Cat) theme
@ -18,7 +29,9 @@
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 +56,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:

View file

@ -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

View file

@ -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 }}"
changed_when: false
#- name: "Set vim lightline colorscheme"
# ansible.builtin.lineinfile:

View file

@ -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