Commit 535761be authored by Nikolai Gulatz's avatar Nikolai Gulatz
Browse files

Merge branch '2-migrate-to-ansible' into 'master'

Resolve "Migrate to ansible"

Closes #2

See merge request !4
parents 6420b6e5 7abcc860
roles/avanov.pyenv
# laptopSetupPlaybook
Set up a local development environment.
## Initial setup
1. Install requirements
* `ansible-galaxy install --force -r requirements.yml -p roles/`
2. Ping host
* `ansible all -i hosts -m ping`
3. (On first run only!) Update all packages
* `ansible all -i hosts -m apt -a "upgrade=yes update_cache=yes" --become`
4. (On first run only!) Reboot machine
* `ansible all -i hosts -m reboot --become`
5. Run the playbook
* `ansible-playbook -i hosts playbook.yml`
[defaults]
remote_user = sokratis
remote_port = 22
cow_selection = small
retry_files_enabled = False
host_key_checking = False
[defaults]
remote_user = root
remote_port = 22
cow_selection = small
retry_files_enabled = False
host_key_checking = False
---
python_dependency_list:
- python3
- ssh-askpass
- auditd
- make
- build-essential
- libssl-dev
- zlib1g-dev
- libbz2-dev
- libreadline-dev
- libsqlite3-dev
- wget
- curl
- llvm
- libncurses5-dev
- libncursesw5-dev
- xz-utils
- tk-dev
- libffi-dev
- liblzma-dev
- python3-openssl
- python-openssl
- git
- python-wheel
- python-dev
- python3-pip
- python-pip
- python3-setuptools
- python-setuptools
- git
- vim
- mysql-client
pip_package_list:
- setuptools
- cookiecutter
- jupyterlab
- jupytext
- nbconflux
- requests
- html5lib
- papermill
docker_requirements:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
rbenv_requirements:
- autoconf
- bison
- build-essential
- libssl-dev
- libyaml-dev
- libreadline-dev
- zlib1g-dev
- libncurses5-dev
- libffi-dev
- libgdbm5
- libgdbm-dev
# avanov.pyenv vars
pyenv_env: "user"
pyenv_python_versions: ["3.7.3"]
pyenv_global: "3.7.3"
pyenv_virtualenvs: [{ venv_name: "latest", py_version: "3.7.3" }]
pip_package_root: /home/{{ ansible_user_id }}/.local/bin/
# Ruby vars
rbenv_ruby_version: 2.5.1
rbenv_root: /home/{{ ansible_user_id }}/.rbenv
# node vars
npm_packages_root: /home/{{ ansible_user_id }}/.npm-packages
ansible_user_id: "{{ ansible_user }}"
[all:vars]
ansible_python_interpreter="/usr/bin/python3.6"
physical_ip="{{ ansible_host }}"
[all]
localhost ansible_connection=local
---
- hosts: all
vars_files:
- defaults/main.yml
environment:
RBENV_ROOT: '{{ rbenv_root }}'
NPM_PACKAGES: '{{ npm_packages_root }}'
PATH: '{{ rbenv_root }}/bin:{{ rbenv_root }}/shims:{{ npm_packages_root }}/bin:{{ pip_package_root }}:{{ ansible_env.PATH }}'
pre_tasks:
- name: Update cache
apt:
update_cache: yes
become: true
- name: install dependencies for python setup
apt:
name: "{{ python_dependency_list }}"
state: present
become: true
- name: Install pip packages
pip:
name: "{{ pip_package_list }}"
state: latest
executable: pip
become: true
- name: Install docker requirements
apt:
name: "{{ docker_requirements }}"
state: present
become: true
- name: install poetry
shell: curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
- name: Add nodejs source file
shell: curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
- name: install nodejs 10.x
apt:
name: nodejs
state: present
update_cache: yes
become: true
- name: install rbenv requirements
apt:
name: "{{ rbenv_requirements }}"
state: present
become: true
tasks:
- name: configure instaffo poetry repositories
shell: ~/.poetry/bin/poetry config repositories.instaffo https://pypi.instaffo.tech
- name: Docker Installation Block
block:
- name: add docker key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: add docker repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: install docker and docker compose
apt:
name: ['docker-ce', 'docker-ce-cli', 'containerd.io', 'docker-compose']
state: present
update_cache: yes
- name: Add user to docker group
user:
name: "{{ ansible_user_id }}"
groups: docker
append: yes
become: true
- name: rbenv Installation Block
block:
- name: clone rbenv
git:
repo: https://github.com/rbenv/rbenv.git
dest: ~/.rbenv
- name: clone ruby plugins
git:
repo: https://github.com/rbenv/ruby-build.git
dest: ~/.rbenv/plugins/ruby-build
- name: add rbenv path to .bashrc
blockinfile:
path: /home/{{ ansible_user_id }}/.bashrc
block: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
- name: Install ruby
shell: rbenv install "{{ rbenv_ruby_version }}"
- name: make ruby version global
shell: rbenv global "{{ rbenv_ruby_version }}"
- name: Node Configuration Block
block:
- name: Create NPM_PACKAGES directory
file:
path: "{{ npm_packages_root }}"
state: directory
- name: set npm prefix
shell: npm config set prefix "{{ npm_packages_root }}"
- name: add NPM_PACKAGES path to .bashrc
lineinfile:
dest: /home/{{ ansible_user_id }}/.bashrc
line: export PATH="$PATH:$NPM_PACKAGES/bin"
- name: install npm@latest globally
shell: npm install npm@latest -g
- name: Yarn Installation Block
block:
- name: add public yarn key
apt_key:
url: https://dl.yarnpkg.com/debian/pubkey.gpg
state: present
- name: add yarn in apt source list
apt_repository:
repo: "deb https://dl.yarnpkg.com/debian/ stable main"
state: present
- name: install yarn
apt:
name: yarn
state: latest
update_cache: yes
become: true
- name: Change vm.max_map_count value
sysctl:
name: vm.max_map_count
value: 262144
state: present
become: true
- name: Change fs.inotify.max_user_watches value
sysctl:
name: fs.inotify.max_user_watches
value: 524288
state: present
become: true
post_tasks:
- name: Install jupyter labextension - jupyter-widgets/jupyterlab-manager
shell: ~/.local/bin/jupyter labextension install @jupyter-widgets/jupyterlab-manager
- name: Install jupyter labextension - jupyterlab/toc
shell: ~/.local/bin/jupyter labextension install @jupyterlab/toc
- name: Install jupyter labextension - jupyterlab/celltags
shell: ~/.local/bin/jupyter labextension install @jupyterlab/celltags
- name: install bundler
shell: gem install bundler
- name: install inspec
shell: gem install inspec
- name: install inspec-bin
shell: gem install inspec-bin
roles:
- role: avanov.pyenv
become: true
tags: ["pyenv"]
---
- src: https://github.com/avanov/ansible-galaxy-pyenv
path: roles
name: avanov.pyenv
version: master
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment