ansible
Friday 13 September 2024

Ansible

I use ansible to install the necessary tools I need in development when using a new machine to start quickly. I have a playbook that installs all the tools I need.

My Ansible File

 1- hosts: localhost
 2  become: true
 3  pre_tasks: 
 4    - name: Update cache
 5      apt:
 6        update_cache: true
 7      tags:
 8      - zsh
 9      - nodejs
10      - tmux
11  tasks: 
12  - name: Install zsh
13    apt: name=zsh
14    tags: 
15    - zsh
16  - name: Change shell
17    shell: chsh -s `which zsh`
18    tags:
19    - zsh
20  - name: Install ohmyzsh (:XD)
21    shell: curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
22    tags:
23    - zsh
24  - name: Install the zsh plugins for auto suggestions
25    shell: git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions
26    tags:
27    - zsh
28  - name: Update our zshrc
29    shell: sed -i -e 's/plugins=(git)/plugins=(git zsh-autosuggestions)/g' ~/.zshrc
30    tags:
31    - zsh
32  - name: Install tmux
33    apt:  name=tmux
34    tags:
35    - tmux
36  - name: Install nvm
37    shell: >
38     curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
39     creates=/home/{{ ansible_user_id }}/.nvm/nvm.sh     
40    tags:
41    - nodejs
42  - name: Install node latest version
43    shell: >
44      /bin/bash -c "source ~/.nvm/nvm.sh && nvm install node"
45      creates=/home/{{ ansible_user_id }}/.nvm/alias      
46    tags:
47    - nodejs
48  - name: Install node version 20.10
49    shell: >
50     /bin/bash -c "source ~/.nvm/nvm.sh && nvm install 20.10"
51     creates=/home/{{ ansible_user_id }}/.nvm/alias     
52    tags:
53    - nodejs

Tools

  • zsh
  • zsh autosuggestions
  • oh-my-zsh
  • tmux
  • nvm
  • nodejs latest version
  • nodejs version 20.10

How use it

  1. Install ansible
  2. Clone the repository
1   git clone https://github.com/Adosh74/ansible
  1. move to the directory
1   cd ansible
  1. Run the playbook
1   ansible-playbook local.yml

Backlinks