Skip to content

Commit

Permalink
add pipx support (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeeq authored Jan 7, 2025
1 parent c207cd0 commit e5977f1
Show file tree
Hide file tree
Showing 31 changed files with 933 additions and 66 deletions.
19 changes: 19 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# profile: basic
profile: null

# enable_list:
# - yaml

skip_list:
- role-name[path]
- yaml[line-length]
# - name
# - tags:formatting,yaml


# To skip task from verifying
# add comment # noqa: command-instead-of-module
## or
# tags:
# - skip_ansible_lint
667 changes: 667 additions & 0 deletions .ansible-lint-ignore

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ RUN dnf clean all \
&& dnf install -y \
python3-pip \
systemd \
pipx \
ShellCheck \
python3-argcomplete \
python3-psutil \
&& dnf clean all

RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
Expand All @@ -27,19 +30,17 @@ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;

# pipx install --global --include-deps --force --preinstall ansible-lint --preinstall pywinrm ansible
# https://pypi.org/project/pip/
RUN pip3 install --no-cache-dir --upgrade pip==24.3.1 && \
pip3 install --no-cache-dir \
# https://pypi.org/project/ansible/
ansible==10.5.0 \
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/ansible-lint/
ansible-lint==24.9.2 \
ansible-lint
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/ansible/
ansible
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/yamllint/
yamllint==1.35.1 \
# https://pypi.org/project/packaging/
packaging==24.1 \
# https://pypi.org/project/pyOpenSSL/
pyOpenSSL==24.2.1
yamllint

# Dive
RUN curl -LO https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.tar.gz && \
Expand Down
34 changes: 25 additions & 9 deletions Dockerfile-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,39 @@ RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
python3-pip \
# pipx \
python3-venv \
sudo \
&& apt-get clean all

### Workaround for old pipx package in Ubuntu 24.04 repos: https://github.com/pypa/pipx/issues/1481
# RUN pipx ensurepath \
# && pipx install pipx \
# && apt remove -y pipx

# RUN ~/.local/bin/pipx install pipx --global \
# && pipx uninstall pipx

# RUN pipx ensurepath \
# && pipx ensurepath --global
RUN pip3 install --break-system-packages --no-cache-dir pipx
###

# https://pypi.org/project/pip/
# rm -rfv /usr/lib/*/EXTERNALLY-MANAGED
# RUN pip3 install --break-system-packages --no-cache-dir --upgrade pip==24.3.1 && \
RUN pip3 install --break-system-packages --no-cache-dir \
# https://pypi.org/project/ansible/
ansible==10.5.0 \
# https://pypi.org/project/pip/
# pipx install --global --include-deps --force --preinstall ansible-lint --preinstall pywinrm ansible
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/ansible-lint/
ansible-lint==24.9.2 \
ansible-lint
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/ansible/
ansible
RUN pipx install --global --force --include-deps \
# https://pypi.org/project/yamllint/
yamllint==1.35.1 \
# https://pypi.org/project/packaging/
packaging==24.1 \
# https://pypi.org/project/pyOpenSSL/
pyOpenSSL==24.2.1
yamllint


RUN useradd ${UBUNTU_USERNAME} && usermod -aG sudo ${UBUNTU_USERNAME}

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,16 @@ echo 2 > /sys/class/backlight/acpi_video0/brightness
```
flatpak override com.valvesoftware.Steam --filesystem=${PATH_TO_FILESYSTEM}
## If your games don't load/start and those are stored on NTFS
# NTFS mount needs to be done as user
# https://github.com/ValveSoftware/Proton/wiki/Using-a-NTFS-disk-with-Linux-and-Windows#editing-fstab

## cat /etc/fstab
/dev/nvme1n1p2 /mnt/dntfs auto uid=1000,gid=1000,rw,user,exec,umask=000 0 0

### only worked after reboot, CLI commands with the same options passed didn't work (still NTFS was mounted as root), i.e.
❯ mount.ntfs-3g -o uid=1000,gid=1000,dmask=0022,fmask=0133 /dev/nvme1n1p2 /mnt/dntfs
```

18. Terminator fails to open with an error `terminator:24:<module>:ModuleNotFoundError: No module named 'psutil'`, try reinstalling `dnf reinstall python3-psutil` to fix it
Expand Down
2 changes: 2 additions & 0 deletions playbooks/group_vars/aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ flatpak_apps:
# https://github.com/ishantanu/awesome-kubectl-plugins
krew_plugins:
- hns

aws_cli_session_manager_plugin_architecture_common_name: "arm64"
31 changes: 15 additions & 16 deletions playbooks/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dnf_pkgs:
- cargo
- python3-argcomplete
- python3-psutil
- sqlite3

dnf_gui_pkgs:
- clamtk
Expand Down Expand Up @@ -102,29 +103,27 @@ flatpak_repos:
- name: flathub
url: https://flathub.org/repo/flathub.flatpakrepo

pip_apps:
pip_apps: []
# fails on newer Ubuntu as it OS managed
# - name: pip
# virtualenv_enabled: false
- name: pyOpenSSL
virtualenv_enabled: false
- name: ansible
virtualenv_enabled: false
# - name: pyOpenSSL
# virtualenv_enabled: false
# - name: argcomplete
# virtualenv_enabled: false
- name: azure-cli
virtualenv_enabled: true
# virtualenv_python: "python3.11"
- name: ansible-lint
virtualenv_enabled: true
- name: yamllint
virtualenv_enabled: false
# - name: psutil
# virtualenv_enabled: false
- name: pywinrm
virtualenv_enabled: false

pipx_apps:
- name: ansible-lint
- name: ansible
install_apps: true
inject_packages:
- pywinrm
# - ansible-lint
- name: azure-cli
- name: yamllint
- name: niet
virtualenv_enabled: true

gnome_extension_owner: "{{ user_name }}"
gnome_extension_path: "/home/{{ gnome_extension_owner }}/.local/share/gnome-shell/extensions/"
Expand Down Expand Up @@ -161,7 +160,7 @@ gnome_extension_ids: "{{ gnome_shell_extensions }}"
# terragrunt_version: 0.31.8
# https://releases.hashicorp.com/vagrant
# https://github.com/hashicorp/vagrant/issues/13527
vagrant_version: 2.4.1
# vagrant_version: 2.4.1
# https://github.com/boz/kail/releases
# kail_version: 0.16.1

Expand Down
2 changes: 2 additions & 0 deletions playbooks/group_vars/x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ krew_plugins:

dnf_extra_pkgs:
- steam-devices

aws_cli_session_manager_plugin_architecture_common_name: "64bit"
3 changes: 2 additions & 1 deletion playbooks/jenkins.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: Jenkins
hosts: "{{ hosts_to_deploy | default('local') }}"
# hosts: "{{ hosts_to_deploy | default('local') }}"
hosts: mikeeClevo
become: true
roles:
- servers/apps/jenkins
5 changes: 3 additions & 2 deletions playbooks/restart-hypervisor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
state: present

- name: Check if reboot required
shell: |
ansible.builtin.shell: |
needs-restarting -r
register: reboot_required
changed_when: reboot_required.rc != 0

- name: Reboot if required
reboot:
ansible.builtin.reboot:
when:
- reboot_required.rc != 0
25 changes: 13 additions & 12 deletions roles/apps/aws-cli/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
- name: Install PIP aws-cli in virtualenv
pip:
# - name: Install PIP aws-cli in virtualenv
# pip:
# name: "https://github.com/aws/aws-cli/archive/refs/tags/{{ aws_cli_version }}.tar.gz"
# state: present
# virtualenv: "{{ virtualenv_install_path }}/aws-cli"
# virtualenv_python: "python3.12"

- name: Install PIPx aws-cli
community.general.pipx:
name: "https://github.com/aws/aws-cli/archive/refs/tags/{{ aws_cli_version }}.tar.gz"
state: present
virtualenv: "{{ virtualenv_install_path }}/aws-cli"
virtualenv_python: "python3.12"

- name: Create a symbolic link for aws-cli
file:
src: "{{ virtualenv_install_path }}/aws-cli/bin/aws"
dest: "/usr/local/bin/aws"
owner: root
group: root
state: link
install_deps: true
global: true
python: "python3.12"
force: true
26 changes: 26 additions & 0 deletions roles/apps/aws-cli/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,29 @@

- include_tasks: install.yml
when: installed_aws_cli_version.stdout != aws_cli_version

- name: Install Session Manager plugin on Fedora
dnf:
name: "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_{{ aws_cli_session_manager_plugin_architecture_common_name }}/session-manager-plugin.rpm"
state: present
disable_gpg_check: true
when:
- ansible_distribution == "Fedora"

- name: Install Session Manager plugin on Ubuntu
apt:
deb: "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_{{ aws_cli_session_manager_plugin_architecture_common_name }}/session-manager-plugin.deb"
state: present
when:
- ansible_distribution == "Ubuntu"

- name: Create a symbolic link for aws-cli
file:
src: "/opt/pipx/venvs/awscli/bin/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
owner: root
group: root
state: link
loop:
- aws
- aws_completer
2 changes: 1 addition & 1 deletion roles/apps/istioctl/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: "Get installed version of istioctl"
become: true
become_user: "{{ user_name }}"
shell: istioctl version --remote=false
shell: istioctl version --remote=false | awk '{print $3}'
register: installed_istioctl_version
changed_when: false
ignore_errors: true
Expand Down
33 changes: 33 additions & 0 deletions roles/apps/oh_my_zsh/tasks/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,36 @@
url: "https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh"
dest: /usr/share/doc/fzf/examples/key-bindings.zsh
when: ansible_distribution == "Ubuntu"

- name: "Download zsh-completion"
become: true
become_user: "{{ item }}"
git:
repo: 'https://github.com/zsh-users/zsh-completions'
dest: "~/.oh-my-zsh/custom/plugins/zsh-completions"
update: true
with_items:
- "{{ user_name }}"
- root

- name: "Download fzf-tab-completion"
become: true
become_user: "{{ item }}"
git:
repo: 'https://github.com/lincheney/fzf-tab-completion.git'
dest: "~/.oh-my-zsh/custom/plugins/fzf-tab-completion"
update: true
with_items:
- "{{ user_name }}"
- root

- name: "Download fzf-tab"
become: true
become_user: "{{ item }}"
git:
repo: 'https://github.com/Aloxaf/fzf-tab'
dest: "~/.oh-my-zsh/custom/plugins/fzf-tab"
update: true
with_items:
- "{{ user_name }}"
- root
19 changes: 16 additions & 3 deletions roles/apps/oh_my_zsh/templates/oh_my_zsh_zshrc.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
Expand All @@ -15,10 +17,13 @@ plugins=(
zsh-syntax-highlighting
docker
ansible
fzf
dnf
z
colored-man-pages
aws
fzf
# fzf-tab
zsh-completions
{% if item != 'root' %}
vscode
terraform
Expand All @@ -31,7 +36,7 @@ plugins=(
source $ZSH/oh-my-zsh.sh

{% if item != 'root' %}
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$HOME/.cargo/bin:/opt/azure_functions_core_tools:$PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$HOME/.cargo/bin:/opt/azure_functions_core_tools:$HOME/.local/bin:$PATH"
{% endif %}

# Extracting Dockerfile from image
Expand Down Expand Up @@ -71,7 +76,7 @@ export EDITOR=/usr/bin/vim

autoload -U +X bashcompinit && bashcompinit
{% if skip_azure_cli_autocompletion is not defined %}
source /opt/virtualenv/azure-cli/bin/az.completion.sh
source /opt/pipx/venvs/azure-cli/bin/az.completion.sh
{% endif %}

alias git_root='cd $(git rev-parse --show-toplevel)'
Expand All @@ -89,3 +94,11 @@ WORK_PROFILES_PATH="$HOME/.work_profiles"
if [[ -n $WORK_PROFILE ]]; then
source $WORK_PROFILES_PATH/.zshrc
fi

{# source $HOME/.oh-my-zsh/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
# only aws command completion
zstyle ':completion:*:*:aws' fzf-search-display true
# or for everything
# zstyle ':completion:*' fzf-search-display true #}

autoload -U compinit && compinit //override comp
2 changes: 1 addition & 1 deletion roles/apps/packer/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Get installed version
shell: packer --version
shell: packer --version | awk '{print $2}' | cut -d'v' -f2
register: installed_packer_version
changed_when: false
ignore_errors: true
Expand Down
2 changes: 2 additions & 0 deletions roles/apps/vagrant/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ vagrant_plugins:
vagrant_embedded_plugins:
- winrm
- winrm-elevated

vagrant_plugins_reinstall: false
Loading

0 comments on commit e5977f1

Please sign in to comment.