-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration improvements
- Loading branch information
Showing
11 changed files
with
154 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
ENV['ANSIBLE_ROLES_PATH'] = "../" | ||
|
||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.vm.box = "bento/ubuntu-16.04" | ||
config.vm.hostname = "ansible-role-docker" | ||
|
||
config.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"] | ||
v.customize ["modifyvm", :id, "--memory", "256"] | ||
end | ||
|
||
config.vm.provision "ansible" do |ansible| | ||
ansible.playbook = "tests/vagrant.yml" | ||
# ansible.inventory_path = "tests/inventory" | ||
ansible.verbose = "vv" | ||
ansible.limit = "all" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
--- | ||
docker_apt_cache_valid_time: 3600 | ||
|
||
# apt repository key url | ||
apt_key_url: hkp://p80.pool.sks-keyservers.net:80 | ||
# apt repository key signature | ||
apt_key_sig: 58118E89F3A912897C070ADBF76221572C52609D | ||
# apt repository name for docker | ||
apt_repository: deb https://apt.dockerproject.org/repo ubuntu-{{ ansible_distribution_release }} main | ||
|
||
docker_opts: "" | ||
|
||
# check new docker package version | ||
docker_update: no | ||
|
||
docker_py_install: true | ||
docker_py_version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- { role: ./, | ||
docker_opts: "-H unix:///var/run/docker.sock" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,105 @@ | ||
--- | ||
- name: add docker repo apt key | ||
- name: check ubuntu version | ||
fail: | ||
msg: "{{ ansible_distribution_version }} is not an acceptable version of Ubuntu for this role" | ||
when: ansible_distribution_version|version_compare(15.04, '<') | ||
|
||
- name: add docker repository key | ||
apt_key: | ||
keyserver=p80.pool.sks-keyservers.net | ||
id=58118E89F3A912897C070ADBF76221572C52609D | ||
state=present | ||
keyserver: "{{ apt_key_url }}" | ||
id: "{{ apt_key_sig }}" | ||
state: present | ||
|
||
- name: add docker repository | ||
apt_repository: | ||
repo="deb https://apt.dockerproject.org/repo ubuntu-xenial main" | ||
update_cache=yes | ||
repo: "{{ apt_repository }}" | ||
update_cache: yes | ||
|
||
- name: install docker | ||
apt: name=docker-engine | ||
- name: install docker package | ||
apt: | ||
name: docker-engine | ||
state: "{{ 'latest' if docker_update else 'present' }}" | ||
update_cache: yes | ||
cache_valid_time: "{{ docker_apt_cache_valid_time }}" | ||
|
||
- name: create /etc/systemd/system/docker.service.d directory | ||
- name: create systemd configuration directory for Docker service | ||
file: | ||
dest=/etc/systemd/system/docker.service.d | ||
recurse=yes | ||
state=directory | ||
dest: /etc/systemd/system/docker.service.d | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
when: docker_opts != "" | ||
|
||
- name: set docker daemon options (systemd) | ||
copy: | ||
content: | | ||
[Service] | ||
Environment="DOCKER_OPTS={{ docker_opts.rstrip('\n') }}" | ||
dest: /etc/systemd/system/docker.service.d/env.conf | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: | ||
- reload systemd | ||
- restart docker | ||
when: docker_opts != "" | ||
|
||
- name: uploads docker configuration file | ||
- name: create docker daemon configuration file | ||
template: | ||
src: 'docker/docker.conf.j2' | ||
dest: '/etc/systemd/system/docker.service.d/docker.conf' | ||
src: docker.conf | ||
dest: /etc/systemd/system/docker.service.d/docker.conf | ||
notify: | ||
- 'daemon-reload' | ||
- 'restart docker' | ||
- reload systemd | ||
- restart docker | ||
when: docker_opts != "" | ||
|
||
- name: install pip, python-dev package with apt | ||
apt: | ||
pkg: "{{ item }}" | ||
state: latest | ||
update_cache: yes | ||
cache_valid_time: "{{ docker_apt_cache_valid_time }}" | ||
with_items: | ||
- python-dev | ||
- python-pip | ||
|
||
- name: upgrade latest docker-py | ||
pip: | ||
name: "{{ item.name }}" | ||
state: latest | ||
with_items: | ||
- { name: docker-py, version: "{{ docker_py_version }}", install: "{{ docker_py_install }}" } | ||
when: (item.version=="latest" and item.install) | ||
|
||
- name: install docker-py | ||
pip: name=docker-py | ||
pip: | ||
name: "{{ item.name }}" | ||
state: present | ||
version: "{{ item.version }}" | ||
with_items: | ||
- { name: docker-py, version: "{{ docker_py_version }}", install: "{{ docker_py_install }}" } | ||
when: (item.version!="latest" and item.install) | ||
|
||
- name: check if /etc/updatedb.conf exists | ||
stat: | ||
path: /etc/updatedb.conf | ||
register: _updatedb_conf_exists | ||
|
||
- name: ensure updatedb does not index /var/lib/docker | ||
lineinfile: | ||
dest: /etc/updatedb.conf | ||
state: present | ||
backrefs: yes | ||
regexp: '^PRUNEPATHS="(/var/lib/docker )?(.*)"$' | ||
line: 'PRUNEPATHS="/var/lib/docker \2"' | ||
when: _updatedb_conf_exists.stat.exists | ||
|
||
- name: start docker | ||
service: | ||
name: docker | ||
state: started | ||
|
||
- meta: flush_handlers | ||
- name: update facts if docker0 is not defined | ||
action: setup filter="ansible_docker0" | ||
when: ansible_docker0 is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[local] | ||
localhost ansible_connection=local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
- hosts: localhost | ||
remote_user: root | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- ansible-role-docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- ansible-role-docker |