Skip to content

Commit 65dac48

Browse files
Added ubuntu playbook and task
1 parent 630767d commit 65dac48

File tree

5 files changed

+191
-0
lines changed

5 files changed

+191
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.retry
22
.DS_Store
33
.idea
4+
get-pip.py

ansible_ubuntu.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
- hosts: localhost
3+
tasks:
4+
- name: Update apt and install required system packages
5+
apt:
6+
pkg:
7+
- autoconf
8+
- automake
9+
- coreutils
10+
- curl
11+
- gnu-time
12+
- gpg
13+
- htop
14+
- imagemagick@6
15+
- libtool
16+
- libxslt
17+
- libyaml
18+
- openssl
19+
- git
20+
- pkg-config
21+
- rbenv
22+
- ruby-build
23+
- rbenv-default-gems
24+
- rbenv-gemset
25+
- readline
26+
- sqlite3
27+
- tmux
28+
- unzip
29+
- vim
30+
- zlib
31+
- zsh
32+
state: latest
33+
update_cache: true
34+
35+
- name: Get the path to ZSH
36+
become: false
37+
local_action: command which zsh
38+
register: zsh_path
39+
40+
- name: "Ensure zsh is in allowed shells"
41+
lineinfile:
42+
path: /etc/shells
43+
line: "{{ zsh_path.stdout }}"
44+
become: true
45+
46+
- name: Install Oh My ZSH
47+
shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
48+
args:
49+
creates: "$HOME/{{ lookup('env', 'USER') }}/.oh-my-zsh"
50+
51+
- name: Set ZSH as the default shell
52+
shell: chsh -s $(which zsh) {{ lookup('env', 'USER') }}
53+
become: true
54+
55+
- name: Install nvm
56+
become: no
57+
shell: >
58+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash
59+
args:
60+
executable: /bin/bash
61+
chdir: "$HOME"
62+
creates: "$HOME/.nvm/nvm.sh"
63+
64+
- name: Install node
65+
become: no
66+
shell: >
67+
. {{ ansible_env.HOME }}/.nvm/nvm.sh && nvm install {{ item }}
68+
args:
69+
executable: /bin/bash
70+
chdir: "{{ ansible_env.HOME }}"
71+
creates: "{{ ansible_env.HOME }}/.nvm/versions/{{ item }}"
72+
loop:
73+
- 16.15
74+
75+
- name: "Install Default Ruby"
76+
shell: |
77+
rbenv install 3.2.0
78+
rbenv global 3.2.0
79+
gem install bundler
80+
echo 'bundler' >> "$(brew --prefix rbenv)/default-gems"
81+
echo 'gem: --no-document' >> ~/.gemrc
82+
83+
- name: Install yarn packages
84+
shell: yarn global add {{ item }}
85+
with_items:
86+
- @angular/cli
87+
- typescript

bin/bootstrap_ubuntu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
3+
python3 get-pip.py
4+
sudo pip3 install --ignore-installed ansible
5+
ansible-galaxy install -r requirements.yml
6+
7+
ansible-playbook -i "localhost," -c local ansible_ubuntu.yml --ask-become-pass

tasks/docker.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
- name: Remove possible Docker install from docker.com
3+
# if installed from https://docs.docker.com/engine/install/ubuntu/
4+
become: true
5+
apt:
6+
state: absent
7+
pkg:
8+
- docker-ce
9+
10+
- name: Remove possible docker-compose installed from github
11+
# if installed from https://github.com/docker/compose/releases/download/
12+
become: true
13+
file:
14+
path: '/usr/local/bin/docker-compose'
15+
state: absent
16+
17+
- name: Install Docker from Ubuntu APT
18+
become: true
19+
apt:
20+
state: present
21+
pkg:
22+
- runc
23+
- containerd
24+
- docker.io
25+
- docker-compose
26+
27+
- name: Allow running Docker without sudo
28+
become: true
29+
user:
30+
name: "{{ ansible_user_id }}"
31+
groups: docker
32+
append: yes
33+
34+
# Then, you have to explicitly start docker.service
35+
# systemctl start docker.service.
36+
# With service module, when running in Docker in molecule
37+
# we get this error FAILED! =>
38+
# "msg": "Could not find the requested service docker: host"
39+
# with systemd module instead it works
40+
- name: Do NOT enable service docker on boot
41+
become: yes
42+
ansible.builtin.systemd:
43+
name: docker.service
44+
enabled: no
45+
46+
# This way, as soon as we run a docker command docker.service starts
47+
- name: Enable docker.socket on boot
48+
become: yes
49+
ansible.builtin.systemd:
50+
name: docker.socket
51+
enabled: yes

tasks/ubuntu/google-chrome.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
- name: Copy Google Chrome apt key
3+
# The apt_key file is expected to be found on the remote host
4+
# so we first need to copy it
5+
become: true
6+
copy:
7+
src: "{{ playbook_dir }}/tasks/files/keys/google_linux_signing_key.pub"
8+
dest: "/tmp/"
9+
mode: 0600
10+
11+
- name: Add Google Chrome apt key
12+
become: true
13+
apt_key:
14+
# url: https://dl-ssl.google.com/linux/linux_signing_key.pub
15+
# use locally save key to avoid possible temporary failures
16+
file: "/tmp/google_linux_signing_key.pub"
17+
state: present
18+
19+
- stat: path=/etc/default/google-chrome
20+
register: etc_default_google_chrome
21+
22+
# This way we avoid Chrome setting up the APT repository:
23+
# we want to set up it ourselves
24+
- name: Make sure /etc/default/google-chrome exists
25+
become: true
26+
file:
27+
path: /etc/default/google-chrome
28+
state: touch
29+
mode: 0644
30+
when: etc_default_google_chrome.stat.exists is defined and not etc_default_google_chrome.stat.exists
31+
32+
- name: Add Google Chrome apt repository
33+
become: true
34+
apt_repository:
35+
repo: deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
36+
state: present
37+
filename: google-chrome
38+
39+
- name: Install Google Chrome
40+
become: true
41+
apt:
42+
update_cache: yes
43+
state: present
44+
pkg:
45+
- google-chrome-stable

0 commit comments

Comments
 (0)