Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Jean committed Jan 25, 2022
0 parents commit 444a365
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ansible:
./scripts/install_ansible.sh

configure: ansible
ansible-playbook configure.yml --ask-become-pass
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# wsl-setup

Une configuration de base pour débuter avec le WSL.

# Installation du WSL

Suivre la [doc dédiée à l'installation du WSL](https://docs.microsoft.com/fr-fr/learn/modules/get-started-with-windows-subsystem-for-linux/).

# Configuration du WSL

Clonez ce repo, puis

```shell
make configure
```

> Sous le capot, on utilise `ansible` pour provisionner toute une suite d'outils. En faisant cela, on garantit qu'un développeur peut simplement relancer la même commande pour installer de nouveaux outils/de nouvelles dépendances.
10 changes: 10 additions & 0 deletions configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

- name: install required tools
hosts: localhost
become: yes
vars:
docker_compose_version: 1.29.2
docker_users: ["{{ lookup('env', 'USER') }}"]
roles:
- developer
6 changes: 6 additions & 0 deletions roles/developer/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: restart docker daemon
service:
name: docker
state: restarted
10 changes: 10 additions & 0 deletions roles/developer/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

- name: install terraform
include_tasks: tools/terraform.yml

- name: install docker
include_tasks: tools/docker.yml

- name: install gh cli
include_tasks: tools/gh_cli.yml
50 changes: 50 additions & 0 deletions roles/developer/tasks/tools/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---

- name: ensure obsolete packages are absent
apt:
name: ['docker', 'docker-engine', 'docker.io', 'containerd', 'runc']
state: absent
purge: yes

- name: ensure dependencies are installed
apt:
name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common']
state: present
update_cache: yes

- name: add docker apt fingerprint
apt_key:
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present

- name: add docker apt repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present

- name: install docker
apt:
name: ['docker-ce', 'docker-ce-cli', 'containerd.io']
state: present
update_cache: yes

- name: ensure docker group exists
group:
name: docker
state: present

- name: add users to docker group
user:
name: "{{ item }}"
append: yes
groups: docker
with_items: "{{ docker_users }}"
notify: restart docker daemon

# docker compose
- name: install docker compose
get_url:
url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 0755
23 changes: 23 additions & 0 deletions roles/developer/tasks/tools/gh_cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

# curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
# sudo apt update
# sudo apt install gh

- name: add guthub cli apt key
apt_key:
url: https://cli.github.com/packages/githubcli-archive-keyring.gpg
state: present

- name: add github cli apt repository
apt_repository:
repo: deb [arch=amd64] https://cli.github.com/packages stable main
state: present

- name: install gh cli package
apt:
name:
- gh
state: latest
update_cache: yes
27 changes: 27 additions & 0 deletions roles/developer/tasks/tools/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: ensure requirements are present
apt:
name:
- gnupg
- software-properties-common
- curl
state: latest
update_cache: yes

- name: add hashicorp apt key
apt_key:
url: https://apt.releases.hashicorp.com/gpg
state: present

- name: add hashicorp apt repository
apt_repository:
repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main
state: present

- name: install terraform package
apt:
name:
- terraform
state: latest
update_cache: yes
12 changes: 12 additions & 0 deletions scripts/install_ansible.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

which ansible | grep "ansible" &> /dev/null
if [ $? == 0 ]; then
echo "Ansible seems to be already installed. Skipping."
exit 0
fi

apt update
apt install -y software-properties-common make
add-apt-repository --yes --update ppa:ansible/ansible
apt install -y ansible

0 comments on commit 444a365

Please sign in to comment.