implement basic ansible config
This commit is contained in:
127
playbook.yml
Normal file
127
playbook.yml
Normal file
@ -0,0 +1,127 @@
|
||||
---
|
||||
- name: Setup dotfiles configuration
|
||||
hosts: localhost
|
||||
connection: local
|
||||
become: false
|
||||
vars:
|
||||
dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles"
|
||||
|
||||
tasks:
|
||||
- name: Install packages with pacman
|
||||
become: true
|
||||
pacman:
|
||||
name:
|
||||
- neovim
|
||||
- zsh
|
||||
- git
|
||||
- openssh
|
||||
state: present
|
||||
|
||||
- name: Install oh-my-zsh from AUR
|
||||
kewlfft.aur.aur:
|
||||
name: oh-my-zsh-git
|
||||
state: present
|
||||
|
||||
- name: Create necessary directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ ansible_env.HOME }}/.config"
|
||||
- "{{ ansible_env.HOME }}/.ssh"
|
||||
|
||||
- name: Check if neovim config exists
|
||||
stat:
|
||||
path: "{{ dotfiles_dir }}/nvim"
|
||||
register: nvim_config
|
||||
|
||||
- name: Symlink neovim config
|
||||
file:
|
||||
src: "{{ dotfiles_dir }}/nvim"
|
||||
dest: "{{ ansible_env.HOME }}/.config/nvim"
|
||||
state: link
|
||||
force: true
|
||||
when: nvim_config.stat.exists
|
||||
|
||||
- name: Check if zsh config exists
|
||||
stat:
|
||||
path: "{{ dotfiles_dir }}/zsh/.zshrc"
|
||||
register: zsh_config
|
||||
|
||||
- name: Symlink zsh config
|
||||
file:
|
||||
src: "{{ dotfiles_dir }}/zsh/.zshrc"
|
||||
dest: "{{ ansible_env.HOME }}/.zshrc"
|
||||
state: link
|
||||
force: true
|
||||
when: zsh_config.stat.exists
|
||||
|
||||
- name: Change default shell to zsh
|
||||
become: true
|
||||
user:
|
||||
name: "{{ ansible_env.USER }}"
|
||||
shell: /usr/bin/zsh
|
||||
|
||||
- name: Symlink SSH askpass config
|
||||
file:
|
||||
src: "{{ dotfiles_dir }}/ssh_askpass.conf"
|
||||
dest: "{{ ansible_env.HOME }}/.ssh/askpass.conf"
|
||||
state: link
|
||||
force: true
|
||||
when: zsh_config.stat.exists
|
||||
|
||||
- name: Check if git config exists
|
||||
stat:
|
||||
path: "{{ dotfiles_dir }}/git/.gitconfig"
|
||||
register: git_config
|
||||
|
||||
- name: Symlink global git config
|
||||
file:
|
||||
src: "{{ dotfiles_dir }}/git/.gitconfig"
|
||||
dest: "{{ ansible_env.HOME }}/.gitconfig"
|
||||
state: link
|
||||
force: true
|
||||
when: git_config.stat.exists
|
||||
|
||||
- name: Check if kde config exists
|
||||
stat:
|
||||
path: "{{ dotfiles_dir }}/kde"
|
||||
register: kde_config
|
||||
|
||||
- name: Find KDE config files in dotfiles
|
||||
find:
|
||||
paths: "{{ dotfiles_dir }}/kde"
|
||||
patterns: "*"
|
||||
file_type: file
|
||||
register: kde_configs
|
||||
when: kde_config.stat.exists
|
||||
|
||||
- name: Symlink KDE config files
|
||||
file:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ ansible_env.HOME }}/.config/{{ item.path | basename }}"
|
||||
state: link
|
||||
force: true
|
||||
loop: "{{ kde_configs.files }}"
|
||||
when: kde_configs.files is defined
|
||||
|
||||
- name: Install yay if not present (for AUR packages)
|
||||
block:
|
||||
- name: Check if yay is installed
|
||||
command: which yay
|
||||
register: yay_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Install yay from AUR
|
||||
become: true
|
||||
shell: |
|
||||
cd /tmp
|
||||
git clone https://aur.archlinux.org/yay.git
|
||||
cd yay
|
||||
makepkg -si --noconfirm
|
||||
cd ..
|
||||
rm -rf yay
|
||||
when: yay_check.rc != 0
|
||||
|
||||
Reference in New Issue
Block a user