2024-09-05 02:56:43 +00:00
|
|
|
---
|
|
|
|
- name: installs and setups dotfiles and packages
|
|
|
|
hosts: localhost
|
|
|
|
tasks:
|
|
|
|
- name: test loops
|
|
|
|
debug:
|
|
|
|
msg: "{{ ansible_os_family }}"
|
|
|
|
- name: install packages on a debian host
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: latest
|
|
|
|
loop:
|
|
|
|
- vim-nox
|
|
|
|
- git
|
|
|
|
- stow
|
|
|
|
- curl
|
|
|
|
- ranger
|
|
|
|
- tmux
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
become: yes
|
2024-09-28 22:12:43 +00:00
|
|
|
become_user: root
|
2024-09-05 02:56:43 +00:00
|
|
|
|
|
|
|
- name: install packages on redhat host
|
|
|
|
dnf:
|
|
|
|
name:
|
|
|
|
- vim-enhanced
|
|
|
|
- git
|
|
|
|
- stow
|
|
|
|
- curl
|
|
|
|
- ranger
|
|
|
|
- tmux
|
|
|
|
state: latest
|
|
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
become: yes
|
2024-09-28 22:12:43 +00:00
|
|
|
become_user: root
|
|
|
|
|
|
|
|
- name: copy old bash configs to ...bak
|
|
|
|
copy:
|
2024-09-28 22:29:51 +00:00
|
|
|
src: "/home/{{ansible_user_id}}/{{item}}"
|
|
|
|
dest: "/home/{{ansible_user_id}}/{{item}}.bak"
|
2024-09-28 22:12:43 +00:00
|
|
|
loop:
|
|
|
|
- ".bashrc"
|
|
|
|
- ".bash_profile"
|
2024-09-28 22:43:59 +00:00
|
|
|
when: ansible_user_id != "root"
|
2024-09-28 22:12:43 +00:00
|
|
|
|
|
|
|
- name: delete old configs
|
|
|
|
file:
|
2024-09-28 22:29:51 +00:00
|
|
|
path: "/home/{{ansible_user_id}}/{{item}}"
|
2024-09-28 22:12:43 +00:00
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- ".bashrc"
|
|
|
|
- ".bash_profile"
|
2024-09-28 22:43:59 +00:00
|
|
|
when: ansible_user_id != "root"
|
2024-09-05 02:56:43 +00:00
|
|
|
|
|
|
|
- name: link the dotfiles to users home directory
|
|
|
|
command:
|
|
|
|
cmd: stow "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- bash
|
|
|
|
- git
|
|
|
|
- ranger
|
|
|
|
- shellenv
|
|
|
|
- tmux
|
|
|
|
- vim
|