workstation-setup/local.yml

127 lines
2.9 KiB
YAML
Raw Normal View History

2021-12-24 11:17:59 +01:00
---
- hosts: localhost
2021-12-30 13:30:13 +01:00
become: true
2021-12-24 11:17:59 +01:00
connection: local
2021-12-30 13:30:13 +01:00
vars_files:
- vars/packages.yml
vars:
tmp_dir: /tmp-ansibe
discord_url: https://discordapp.com/api/download?format=deb&platform=linux
2021-12-24 12:56:04 +01:00
roles:
- role: gantsign.visual-studio-code
2021-12-24 14:29:45 +01:00
become: true
2021-12-24 12:56:04 +01:00
users:
- username: gianm
2021-12-24 11:17:59 +01:00
tasks:
2021-12-30 13:30:13 +01:00
- name: Creates temporary directory
file:
path: "{{ tmp_dir }}"
state: directory
- name: get script to add repository nodejs
2021-12-27 14:33:54 +01:00
become: true
2021-12-30 13:30:13 +01:00
when: ansible_facts['os_family'] == "Debian"
get_url:
url: "https://deb.nodesource.com/setup_lts.x"
dest: "{{ tmp_dir }}/node-add.sh"
mode: '774'
- name: execute scritp to add repository nodejs
become: true
when: ansible_facts['os_family'] == "Debian"
command: "{{ tmp_dir }}/node-add.sh"
register: source_added
changed_when: source_added.rc != 0
2021-12-27 14:33:54 +01:00
2021-12-30 13:30:13 +01:00
- name: execute scritp to add repository nodejs
2021-12-25 17:27:14 +01:00
become: true
when: ansible_facts['os_family'] == "Debian"
2021-12-30 13:30:13 +01:00
command: "{{ tmp_dir }}/node-add.sh"
register: source_added
changed_when: source_added.rc != 0
2021-12-25 17:27:14 +01:00
2021-12-30 13:30:13 +01:00
- name: DISCORD - Download discord
get_url:
url: "{{ discord_url }}"
dest: "{{ tmp_dir }}/discord.deb"
force: yes
- name: DISCORD - Install my_package
apt:
deb: "{{ tmp_dir }}/discord.deb"
- name: Update apt repository
become: true
when: ansible_facts['os_family'] == "Debian"
command: apt update
- name: Installing {{ packages }}
2021-12-24 14:29:45 +01:00
become: true
2021-12-24 11:17:59 +01:00
package:
2021-12-30 13:30:13 +01:00
name: "{{ item }}"
state: present
with_items: "{{ packages }}"
2021-12-24 12:03:11 +01:00
2021-12-30 13:30:13 +01:00
- name: Set zsh main as command
2021-12-24 12:05:28 +01:00
become: true
2021-12-30 13:30:13 +01:00
command: chsh -s $(which zsh) gianm
register: shell_change
changed_when: shell_change.rc != 0
2021-12-24 12:03:11 +01:00
2021-12-24 12:56:04 +01:00
- name: check if on my zsh is installed
stat:
2021-12-25 17:42:41 +01:00
path: "/home/gianm/.oh-my-zsh"
2021-12-24 12:56:04 +01:00
register: zsh_dir
2021-12-25 17:42:41 +01:00
- name: Install oh my zsh
debug:
msg: "skipping install oh my zsh"
when: zsh_dir.stat.exists
2021-12-27 14:00:58 +01:00
- name: Install oh my zsh
2021-12-27 14:11:20 +01:00
become_user: gianm
2021-12-27 14:00:58 +01:00
git:
repo: https://github.com/ohmyzsh/ohmyzsh.git
2021-12-30 13:30:13 +01:00
version: 'latest'
2021-12-27 14:00:58 +01:00
dest: ~/.oh-my-zsh
depth: 1
2021-12-25 18:14:16 +01:00
- name: Setup .zshrc
2021-12-27 14:11:20 +01:00
become_user: gianm
2021-12-25 17:27:14 +01:00
copy:
src: files/zshrc
2021-12-27 14:11:20 +01:00
dest: ~/.zshrc
2021-12-27 14:00:58 +01:00
mode: 0644
2021-12-25 17:27:14 +01:00
2021-12-27 14:33:54 +01:00
- name: Setup .profile
2021-12-27 14:11:20 +01:00
become_user: gianm
2021-12-25 17:27:14 +01:00
copy:
src: files/profile
2021-12-27 14:11:20 +01:00
dest: ~/.profile
2021-12-27 14:35:32 +01:00
mode: 0644
2021-12-30 13:30:13 +01:00
- name: create local dir for node packages
become_user: gianm
file:
path: ~/.npm-global
state: directory
owner: gianm
mode: 0644
- name: EACCESS fix
become_user: gianm
command: npm config set prefix '~/.npm-global'
register: updated_npm
changed_when: updated_npm.rc != 0
- name: Remove temporary directory
2021-12-30 13:33:08 +01:00
file:
path: "{{ tmp_dir }}"
state: absent
2021-12-30 13:30:13 +01:00
2021-12-30 13:33:14 +01:00
# - name: Setup done rebooting
# become: true
# command: reboot
# register: rebooting
# changed_when: rebooting.rc != 0