Skip to content

Commit

Permalink
docker configuration (#7)
Browse files Browse the repository at this point in the history
* docker configuration

* clean docker install & python3

Co-authored-by: Sviatoslav Sydorenko <[email protected]>
  • Loading branch information
2 people authored and alexsavio committed Aug 8, 2018
1 parent c5335d4 commit c495399
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 161 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ How to run this Ansible playbook
pip install -r requirements.txt
```

3. Launch the ansible playbook

```bash
ansible-playbook playbook.yml
```

Continuous Integration / Delivery
---------------------------------

TODO: travis ?

Testing
-------
Expand Down
6 changes: 2 additions & 4 deletions host_vars/europython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ bin_dir: '{{ home_dir }}/bin'
config_dir_basename: "config"
env_dir_basename: "envfile"

dockers_files_dir: '{{ install_dir }}/dockerfile'
dockers_volumes_dir: '{{ install_dir }}/volume'
dockers_config_dir: '{{ install_dir }}/{{ config_dir_basename }}'
dockers_env_dir: '{{ install_dir }}/{{ env_dir_basename }}'
dockers_files_dir: "{{ install_dir }}/docker"
docker_configuration_repo: "git://github.com/matrixise/europython-config-the-revenant.git"
1 change: 0 additions & 1 deletion hosts.yml

This file was deleted.

2 changes: 1 addition & 1 deletion playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
roles:
- { role: common, become: yes, become_method: sudo, tags: common }
- { role: python, become: yes, become_method: sudo, tags: python }
- { role: docker-compose, tags: docker_compose }
- { role: docker-apps, tags: docker_apps }
- { role: chatbot, tags: chatbot }
3 changes: 2 additions & 1 deletion roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---

root_privileges_present: true
ssh_keys: []
github_users: []
71 changes: 49 additions & 22 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,58 @@
---

- name: prepare | Create directories
file:
path: '{{ item }}'
state: directory
owner: '{{ user }}'
group: '{{ group }}'
- name: Install aptitude
become: true
apt:
pkg: aptitude
state: latest

- name: Install base packages
apt:
pkg: "{{ item }}"
state: latest
with_items:
- '{{ tmp_install_dir }}'
- '{{ bin_dir }}'
- '{{ install_dir }}'
- locales
- tzdata
- build-essential
- curl
- git
- vim
- ntp
- ntpdate
- htop
- bash-completion
- ufw
- sudo
- apt-transport-https
- ca-certificates
- software-properties-common

- name: Update apt repositories cache
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
tags: always

- name: Install dependencies
- name: Upgrade packages
apt:
name: '{{ packages }}'
update_cache: yes
cache_valid_time: 3600
vars:
packages:
- language-pack-en
- build-essential
- python3
- python3-dev
- python3-pip
upgrade: yes

- name: Create /root/.ssh directory
become: true
file:
path: "{{ item }}"
state: directory
with_items:
- /root/.ssh
- /etc/ssh

- name: Set github authorized keys
authorized_key:
key: "https://github.com/{{ item }}.keys"
user: root
with_items: "{{ github_users }}"

- name: Set authorized keys
authorized_key:
key: "{{ item }}"
user: "{{ user | default('root') }}"
with_items: "{{ ssh_keys }}"
File renamed without changes.
55 changes: 55 additions & 0 deletions roles/docker-apps/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---

- name: Install docker dependencies
apt:
name: "{{ item }}"
with_items:
- gnupg2
- apt-transport-https

- name: Trust docker repo key
become: true
apt_key:
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
state: present

- name: Add docker's 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 & python3-pip
apt:
name:
- python3-setuptools
- python3-pip
- docker-ce
state: latest

- name: Install docker-compose
pip:
name: docker-compose
state: latest

- name: Enable docker
service:
name: docker
state: started
enabled: yes

- name: Clone docker configuration
git:
repo: "{{ docker_configuration_repo }}"
dest: "{{ dockers_files_dir }}"
force: yes
clone: yes
update: yes

- name: Configure docker containers
docker_services:
project_src: "{{ dockers_files_dir }}"
build: yes
pull: yes
recreate: always
state: present
6 changes: 0 additions & 6 deletions roles/docker-compose/files/docker-compose.yml

This file was deleted.

57 changes: 0 additions & 57 deletions roles/docker-compose/tasks/install_docker.yml

This file was deleted.

31 changes: 0 additions & 31 deletions roles/docker-compose/tasks/install_docker_compose.yml

This file was deleted.

34 changes: 0 additions & 34 deletions roles/docker-compose/tasks/main.yml

This file was deleted.

10 changes: 6 additions & 4 deletions roles/python/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
---

- name: Install some apt packages
- name: Install python
apt:
name: '{{ packages }}'
vars:
packages:
- python-dev
- python-pip
- python3-dev
- python3-setuptools
- python3-pip

- name: Update pip and setuptools
pip:
name: '{{ item }}'
state: forcereinstall
state: latest
executable: pip3
with_items:
- pip
- setuptools

0 comments on commit c495399

Please sign in to comment.