Skip to content

Instantly share code, notes, and snippets.

@pbassiner
Last active April 12, 2021 07:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbassiner/073a681726ce742db1b4e87de5f75cda to your computer and use it in GitHub Desktop.
Save pbassiner/073a681726ce742db1b4e87de5f75cda to your computer and use it in GitHub Desktop.
Blog Post - Automating My Dev Setup: Ansible and bash script snippets
- include_vars: vars.yml
- name: Download binary files
become: yes
get_url: url={{ item.value.url }} dest=/usr/local/bin/{{ item.value.name }} validate_certs=no mode=0755 force=yes
with_dict: "{{ binaries }}"
- include_vars: vars.yml
- name: Install .deb files
become: yes
apt: deb={{ item.value.url }}
with_dict: "{{ debs }}"
- include_vars: vars.yml
- name: Add apt keys
become: yes
apt_key: keyserver={{ item.value.keyserver }} id={{ item.value.key }}
with_dict: "{{ repositories }}"
- name: Add apt repositories
become: yes
apt_repository: repo={{ item.value.repository }}
with_dict: "{{ repositories }}"
- name: Install packages
become: yes
apt: pkg={{ item }} state=latest update_cache=true
with_items: "{{ packages }}"
- name: Install base packages
sudo: yes
apt:
name: {{ item }}
state: latest
update_cache: true
with_items:
- foo
- bar
- name: Install the package "foo"
apt:
name: foo
state: latest
- include_vars: vars.yml
- name: Download .tar.gz files
get_url: url={{ item.value.url }} dest=/tmp/{{ item.key }}.tar.gz validate_certs=no
with_dict: "{{ targzs }}"
- name: Extract .tar.gz files
unarchive: src=/tmp/{{ item.key }}.tar.gz dest={{ item.value.target_dir }}
with_dict: "{{ targzs }}"
- name: Symlink extracted folders
file: path={{ item.value.target_dir }}/{{ item.value.symlinked_dir }} src={{ item.value.target_dir }}/{{ item.value.original_dir }} state=link
with_dict: "{{ targzs }}"
home: /home/user
repositories:
docker:
repository: deb https://apt.dockerproject.org/repo ubuntu-xenial main
keyserver: hkp://p80.pool.sks-keyservers.net:80
key: 58118E89F3A912897C070ADBF76221572C52609D
packages:
- vim
- zsh
- terminator
debs:
atom:
name: Atom
url: https://atom.io/download/deb
plugins:
- file-icons
- language-scala
- atom-scalariform
targzs:
intellij:
name: IntelliJ IDEA
url: https://download.jetbrains.com/idea/ideaIC-2016.2.5.tar.gz
target_dir: "{{ home }}"
original_dir: idea-IC-162.2228.15
symlinked_dir: ideaIC
binaries:
kubectl:
name: kubectl
url: https://storage.googleapis.com/kubernetes-release/release/v1.4.6/bin/linux/amd64/kubectl
#!/bin/bash
sudo apt-add-repository ppa:ansible/ansible
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get --assume-yes upgrade
sudo apt-get --assume-yes install ansible
sudo apt-get --assume-yes install git
git clone https://github.com/pbassiner/dev-env.git .dev-env
cd .dev-env
ansible-playbook ubuntu.yml -i hosts -vv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment