Skip to content

Commit

Permalink
Playbook test init
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvcc committed Feb 12, 2024
1 parent c32cb1d commit cd064f2
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .cfg/playbook-with-mac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
- name: Install dependencies and configure environment
hosts: localhost
gather_facts: false
tasks:
- name: Update apt cache (Ubuntu)
apt:
update_cache: yes
when: ansible_os_family == 'Debian'

- name: Install essential packages (Ubuntu)
apt:
name: "{{ item }}"
state: present
loop:
- curl
- wget
- git
- gcc
- g++
- libffi-dev
- htop
- xclip
- make
- vim
- python3-dev
- python3-pip
- python3-venv
- libpq-dev
- libsqlite3-dev
- lzma-dev
- libreadline6-dev
- libbz2-dev
- cargo
- bash
- zsh
- neofetch
- unzip
- ripgrep
when: ansible_os_family == 'Debian'

- name: Update Homebrew (macOS)
homebrew:
state: latest
when: ansible_os_family == 'Darwin'

- name: Install essential packages (macOS)
homebrew:
name: "{{ item }}"
loop:
- curl
- wget
- git
- gcc
- libffi
- htop
- xclip
- make
- vim
- python
- postgresql
- sqlite
- xz
- readline
- bzip2
- cargo
- bash
- zsh
- neofetch
- unzip
- ripgrep
when: ansible_os_family == 'Darwin'

- name: Install fd-find (Ubuntu)
apt:
name: fd-find
state: present
when: ansible_os_family == 'Debian'

- name: Install fd-find (macOS)
homebrew:
name: fd
when: ansible_os_family == 'Darwin'

- name: Create symlink for fd
file:
src: "{{ ansible_playbook_dir }}/.local/bin/fd"
dest: "~/.local/bin/fd"
state: link

- name: Install bat (Ubuntu)
apt:
name: bat
state: present
when: ansible_os_family == 'Debian'

- name: Install bat (macOS)
homebrew:
name: bat
when: ansible_os_family == 'Darwin'

- name: Create symlink for bat
file:
src: "{{ ansible_playbook_dir }}/.local/bin/bat"
dest: "~/.local/bin/bat"
state: link

# Other tasks remain the same as in the previous playbook
# ...

- name: Set default shell
hosts: localhost
tasks:
- name: Set default shell to zsh
shell: chsh -s /bin/zsh "{{ ansible_ssh_user }}"
107 changes: 107 additions & 0 deletions .cfg/playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
- name: Install dependencies and configure environment
hosts: localhost
gather_facts: false
tasks:
- name: Update apt cache
apt:
update_cache: yes

- name: Install essential packages
apt:
name: "{{ item }}"
state: present
loop:
- curl
- wget
- git
- gcc
- g++
- libffi-dev
- htop
- xclip
- make
- vim
- python3-dev
- python3-pip
- python3-venv
- libpq-dev
- libsqlite3-dev
- lzma-dev
- libreadline6-dev
- libbz2-dev
- cargo
- bash
- zsh
- neofetch
- unzip
- ripgrep

- name: Install additional packages
apt:
name: "{{ item }}"
state: present
loop:
- fd-find
- bat

- name: Install lsd
apt:
deb: "https://github.com/lsd-rs/lsd/releases/download/v1.0.0/lsd-musl_1.0.0_amd64.deb"
state: present

- name: Create symlinks for fd and bat
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: link
loop:
- { src: "{{ ansible_playbook_dir }}/.local/bin/fd", dest: "~/.local/bin/fd" }
- { src: "{{ ansible_playbook_dir }}/.local/bin/bat", dest: "~/.local/bin/bat" }

- name: Install pyenv
shell: "curl https://pyenv.run | bash"

- name: Install Node.js using fnm
shell: "curl -fsSL https://fnm.vercel.app/install | bash && /bin/zsh -i -c 'fnm install 16'"

- name: Install fzf
git:
repo: https://github.com/junegunn/fzf.git
dest: ~/.fzf
version: master
become: yes

- name: Run fzf install script
command: "~/.fzf/install --all"

- name: Install Neovim, omb, and oh-my-zsh
shell: "./.cfg/scripts/install-neovim.sh && ./.cfg/scripts/install-omb.sh && ./.cfg/scripts/install-omz.sh"

- name: Install Starship prompt
shell: "sh -c 'curl -fsSL https://starship.rs/install.sh | bash -s -- -f'"

- name: Install pipx and packages
pipx:
package: "{{ item }}"
loop:
- ansible
- git+https://github.com/politeauthority/docker-pretty-ps.git#egg=docker-pretty-ps
- ranger-fm
- poetry
- ipython
become: yes

- name: Copy configuration files
copy:
src: "{{ item }}"
dest: "~"
loop:
- .bashrc
- .zshrc

- name: Set default shell
hosts: localhost
tasks:
- name: Set default shell to zsh
shell: chsh -s /bin/zsh "{{ ansible_ssh_user }}"
32 changes: 32 additions & 0 deletions .github/workflows/playbook-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Ansible Playbook Test

on:
push:
branches:
- playbook-wip

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Test Ansible Playbook
run: |
ansible-playbook playbook.yml
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3.10

WORKDIR /root/configs

RUN pip install ansible
116 changes: 116 additions & 0 deletions playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
- name: Install dependencies and configure environment
hosts: localhost
gather_facts: true
tasks:
- name: Update apt cache (Ubuntu)
apt:
update_cache: yes
when: ansible_os_family == 'Debian'

- name: Install essential packages (Ubuntu)
apt:
name: "{{ item }}"
state: present
loop:
- curl
- wget
- git
- gcc
- g++
- libffi-dev
- htop
- xclip
- make
- vim
- python3-dev
- python3-pip
- python3-venv
- libpq-dev
- libsqlite3-dev
- lzma-dev
- libreadline6-dev
- libbz2-dev
- cargo
- bash
- zsh
- neofetch
- unzip
- ripgrep
when: ansible_os_family == 'Debian'

- name: Update Homebrew (macOS)
homebrew:
state: latest
when: ansible_os_family == 'Darwin'

- name: Install essential packages (macOS)
homebrew:
name: "{{ item }}"
loop:
- curl
- wget
- git
- gcc
- libffi
- htop
- xclip
- make
- vim
- python
- postgresql
- sqlite
- xz
- readline
- bzip2
- cargo
- bash
- zsh
- neofetch
- unzip
- ripgrep
when: ansible_os_family == 'Darwin'

- name: Install fd-find (Ubuntu)
apt:
name: fd-find
state: present
when: ansible_os_family == 'Debian'

- name: Install fd-find (macOS)
homebrew:
name: fd
when: ansible_os_family == 'Darwin'

# - name: Create symlink for fd
# file:
# src: "{{ ansible_playbook_dir }}/.local/bin/fd"
# dest: "~/.local/bin/fd"
# state: link
#
# - name: Install bat (Ubuntu)
# apt:
# name: bat
# state: present
# when: ansible_os_family == 'Debian'
#
# - name: Install bat (macOS)
# homebrew:
# name: bat
# when: ansible_os_family == 'Darwin'
#
# - name: Create symlink for bat
# file:
# src: "{{ ansible_playbook_dir }}/.local/bin/bat"
# dest: "~/.local/bin/bat"
# state: link

# Other tasks remain the same as in the previous playbook
# ...

- name: Set default shell
hosts: localhost
tasks:
- name: Set default shell to zsh
shell: chsh -s /bin/zsh "{{ ansible_ssh_user }}"

0 comments on commit cd064f2

Please sign in to comment.