In [1]:
import yaml
with open('ansible-playbook-install-docker.yml') as f:
y = yaml.load(f)
y
Out[1]:
[{'hosts': '192.168.33.10',
'sudo': True,
'tasks': [{'apt': 'name=wget state=present update_cache=yes',
'name': 'install wget'},
{'name': 'install docker',
'shell': 'wget -qO- https://get.docker.com/ | sh'},
{'name': 'start docker', 'service': 'name=docker state=restarted'}],
'user': 'vagrant'}]
In [2]:
!ansible-playbook -v -i inventory ansible-playbook-install-docker.yml
PLAY [192.168.33.10] **********************************************************
GATHERING FACTS ***************************************************************
ok: [192.168.33.10]
TASK: [install wget] **********************************************************
ok: [192.168.33.10] => {"changed": false}
TASK: [install docker] ********************************************************
changed: [192.168.33.10] => {"changed": true, "cmd": "wget -qO- https://get.docker.com/ | sh", "delta": "0:01:08.895721", "end": "2015-04-01 10:28:33.317842", "rc": 0, "start": "2015-04-01 10:27:24.422121", "stderr": "+ [ https://get.docker.com/ = https://get.docker.com/ ]\n+ sh -c apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9\ngpg: requesting key A88D21E9 from hkp server keyserver.ubuntu.com\ngpg: key A88D21E9: public key \"Docker Release Tool (releasedocker) <docker@dotcloud.com>\" imported\ngpg: Total number processed: 1\ngpg: imported: 1 (RSA: 1)\n+ sh -c echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list\n+ sh -c sleep 3; apt-get update; apt-get install -y -q lxc-docker\n+ sh -c docker version", "stdout": "apparmor is enabled in the kernel and apparmor utils were already installed\n/sbin/apparmor_parser\nExecuting: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.MqOReDWAGI --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9\nIgn http://security.ubuntu.com trusty-security InRelease\nIgn http://archive.ubuntu.com trusty InRelease\nHit http://security.ubuntu.com trusty-security Release.gpg\nIgn http://archive.ubuntu.com trusty-updates InRelease\nIgn http://archive.ubuntu.com trusty-backports InRelease\nHit http://security.ubuntu.com trusty-security Release\nHit http://archive.ubuntu.com trusty Release.gpg\nHit http://security.ubuntu.com trusty-security/main Sources\nHit http://archive.ubuntu.com trusty-updates Release.gpg\nHit http://security.ubuntu.com trusty-security/restricted Sources\nHit http://archive.ubuntu.com trusty-backports Release.gpg\nHit http://security.ubuntu.com trusty-security/universe Sources\nGet:1 https://get.docker.com docker InRelease\nHit http://archive.ubuntu.com trusty Release\nHit http://security.ubuntu.com trusty-security/multiverse Sources\nHit http://archive.ubuntu.com trusty-updates Release\nHit http://security.ubuntu.com trusty-security/main amd64 Packages\nIgn https://get.docker.com docker InRelease\nHit http://archive.ubuntu.com trusty-backports Release\nHit http://security.ubuntu.com trusty-security/restricted amd64 Packages\nHit http://security.ubuntu.com trusty-security/universe amd64 Packages\nHit http://archive.ubuntu.com trusty/main Sources\nHit http://archive.ubuntu.com trusty/restricted Sources\nHit http://security.ubuntu.com trusty-security/multiverse amd64 Packages\nHit http://security.ubuntu.com trusty-security/main i386 Packages\nHit http://archive.ubuntu.com trusty/universe Sources\nHit http://security.ubuntu.com trusty-security/restricted i386 Packages\nHit http://archive.ubuntu.com trusty/multiverse Sources\nHit http://security.ubuntu.com trusty-security/universe i386 Packages\nHit http://archive.ubuntu.com trusty/main amd64 Packages\nHit http://security.ubuntu.com trusty-security/multiverse i386 Packages\nHit http://archive.ubuntu.com trusty/restricted amd64 Packages\nHit http://security.ubuntu.com trusty-security/main Translation-en\nHit http://archive.ubuntu.com trusty/universe amd64 Packages\nHit http://archive.ubuntu.com trusty/multiverse amd64 Packages\nHit http://security.ubuntu.com trusty-security/multiverse Translation-en\nGet:2 https://get.docker.com docker Release\nHit http://archive.ubuntu.com trusty/main i386 Packages\nHit http://security.ubuntu.com trusty-security/restricted Translation-en\nHit http://archive.ubuntu.com trusty/restricted i386 Packages\nHit http://security.ubuntu.com trusty-security/universe Translation-en\nHit http://archive.ubuntu.com trusty/universe i386 Packages\nHit http://archive.ubuntu.com trusty/multiverse i386 Packages\nGet:3 https://get.docker.com docker/main amd64 Packages\nHit http://archive.ubuntu.com trusty/main Translation-en\nHit http://archive.ubuntu.com trusty/multiverse Translation-en\nGet:4 https://get.docker.com docker/main i386 Packages\nHit http://archive.ubuntu.com trusty/restricted Translation-en\nHit http://archive.ubuntu.com trusty/universe Translation-en\nGet:5 https://get.docker.com docker/main Translation-en_US\nHit http://archive.ubuntu.com trusty-updates/main Sources\nHit http://archive.ubuntu.com trusty-updates/restricted Sources\nHit http://archive.ubuntu.com trusty-updates/universe Sources\nHit http://archive.ubuntu.com trusty-updates/multiverse Sources\nHit http://archive.ubuntu.com trusty-updates/main amd64 Packages\nHit http://archive.ubuntu.com trusty-updates/restricted amd64 Packages\nHit http://archive.ubuntu.com trusty-updates/universe amd64 Packages\nHit http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages\nHit http://archive.ubuntu.com trusty-updates/main i386 Packages\nHit http://archive.ubuntu.com trusty-updates/restricted i386 Packages\nHit http://archive.ubuntu.com trusty-updates/universe i386 Packages\nHit http://archive.ubuntu.com trusty-updates/multiverse i386 Packages\nHit http://archive.ubuntu.com trusty-updates/main Translation-en\nHit http://archive.ubuntu.com trusty-updates/multiverse Translation-en\nHit http://archive.ubuntu.com trusty-updates/restricted Translation-en\nHit http://archive.ubuntu.com trusty-updates/universe Translation-en\nHit http://archive.ubuntu.com trusty-backports/main Sources\nHit http://archive.ubuntu.com trusty-backports/restricted Sources\nHit http://archive.ubuntu.com trusty-backports/universe Sources\nHit http://archive.ubuntu.com trusty-backports/multiverse Sources\nHit http://archive.ubuntu.com trusty-backports/main amd64 Packages\nHit http://archive.ubuntu.com trusty-backports/restricted amd64 Packages\nHit http://archive.ubuntu.com trusty-backports/universe amd64 Packages\nHit http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages\nHit http://archive.ubuntu.com trusty-backports/main i386 Packages\nHit http://archive.ubuntu.com trusty-backports/restricted i386 Packages\nHit http://archive.ubuntu.com trusty-backports/universe i386 Packages\nHit http://archive.ubuntu.com trusty-backports/multiverse i386 Packages\nHit http://archive.ubuntu.com trusty-backports/main Translation-en\nHit http://archive.ubuntu.com trusty-backports/multiverse Translation-en\nHit http://archive.ubuntu.com trusty-backports/restricted Translation-en\nHit http://archive.ubuntu.com trusty-backports/universe Translation-en\nIgn http://archive.ubuntu.com trusty/main Translation-en_US\nIgn http://archive.ubuntu.com trusty/multiverse Translation-en_US\nIgn http://archive.ubuntu.com trusty/restricted Translation-en_US\nIgn http://archive.ubuntu.com trusty/universe Translation-en_US\nIgn https://get.docker.com docker/main Translation-en_US\nIgn https://get.docker.com docker/main Translation-en\nFetched 7,610 B in 28s (265 B/s)\nReading package lists...\nReading package lists...\nBuilding dependency tree...\nReading state information...\nThe following extra packages will be installed:\n aufs-tools cgroup-lite git git-man liberror-perl lxc-docker-1.5.0\nSuggested packages:\n git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk\n gitweb git-arch git-bzr git-cvs git-mediawiki git-svn\nThe following NEW packages will be installed:\n aufs-tools cgroup-lite git git-man liberror-perl lxc-docker lxc-docker-1.5.0\n0 upgraded, 7 newly installed, 0 to remove and 151 not upgraded.\nNeed to get 8,077 kB of archives.\nAfter this operation, 37.1 MB of additional disk space will be used.\nGet:1 http://archive.ubuntu.com/ubuntu/ trusty/universe aufs-tools amd64 1:3.2+20130722-1.1 [92.3 kB]\nGet:2 https://get.docker.com/ubuntu/ docker/main lxc-docker-1.5.0 amd64 1.5.0 [4,632 kB]\nGet:3 http://archive.ubuntu.com/ubuntu/ trusty/main liberror-perl all 0.17-1.1 [21.1 kB]\nGet:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main git-man all 1:1.9.1-1ubuntu0.1 [698 kB]\nGet:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main git amd64 1:1.9.1-1ubuntu0.1 [2,627 kB]\nGet:6 http://archive.ubuntu.com/ubuntu/ trusty/main cgroup-lite all 1.9 [3,918 B]\nGet:7 https://get.docker.com/ubuntu/ docker/main lxc-docker amd64 1.5.0 [2,092 B]\nFetched 8,077 kB in 20s (400 kB/s)\nSelecting previously unselected package aufs-tools.\n(Reading database ... 59800 files and directories currently installed.)\nPreparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1_amd64.deb ...\nUnpacking aufs-tools (1:3.2+20130722-1.1) ...\nSelecting previously unselected package liberror-perl.\nPreparing to unpack .../liberror-perl_0.17-1.1_all.deb ...\nUnpacking liberror-perl (0.17-1.1) ...\nSelecting previously unselected package git-man.\nPreparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.1_all.deb ...\nUnpacking git-man (1:1.9.1-1ubuntu0.1) ...\nSelecting previously unselected package git.\nPreparing to unpack .../git_1%3a1.9.1-1ubuntu0.1_amd64.deb ...\nUnpacking git (1:1.9.1-1ubuntu0.1) ...\nSelecting previously unselected package cgroup-lite.\nPreparing to unpack .../cgroup-lite_1.9_all.deb ...\nUnpacking cgroup-lite (1.9) ...\nSelecting previously unselected package lxc-docker-1.5.0.\nPreparing to unpack .../lxc-docker-1.5.0_1.5.0_amd64.deb ...\nUnpacking lxc-docker-1.5.0 (1.5.0) ...\nSelecting previously unselected package lxc-docker.\nPreparing to unpack .../lxc-docker_1.5.0_amd64.deb ...\nUnpacking lxc-docker (1.5.0) ...\nProcessing triggers for man-db (2.6.7.1-1) ...\nProcessing triggers for ureadahead (0.100.0-16) ...\nSetting up aufs-tools (1:3.2+20130722-1.1) ...\nSetting up liberror-perl (0.17-1.1) ...\nSetting up git-man (1:1.9.1-1ubuntu0.1) ...\nSetting up git (1:1.9.1-1ubuntu0.1) ...\nSetting up cgroup-lite (1.9) ...\ncgroup-lite start/running\nSetting up lxc-docker-1.5.0 (1.5.0) ...\ndocker start/running, process 5369\nProcessing triggers for ureadahead (0.100.0-16) ...\nSetting up lxc-docker (1.5.0) ...\nProcessing triggers for libc-bin (2.19-0ubuntu6) ...\nClient version: 1.5.0\nClient API version: 1.17\nGo version (client): go1.4.1\nGit commit (client): a8a31ef\nOS/Arch (client): linux/amd64\nServer version: 1.5.0\nServer API version: 1.17\nGo version (server): go1.4.1\nGit commit (server): a8a31ef\n\nIf you would like to use Docker as a non-root user, you should now consider\nadding your user to the \"docker\" group with something like:\n\n sudo usermod -aG docker your-user\n\nRemember that you will have to log out and back in for this to take effect!", "warnings": ["Consider using get_url module rather than running wget"]}
TASK: [start docker] **********************************************************
changed: [192.168.33.10] => {"changed": true, "name": "docker", "state": "started"}
PLAY RECAP ********************************************************************
192.168.33.10 : ok=4 changed=2 unreachable=0 failed=0
In [3]:
!ansible -i inventory 192.168.33.10 --sudo -a 'service docker status'
192.168.33.10 | success | rc=0 >>
docker start/running, process 5516
In [ ]:
Content source: doragon/presentation
Similar notebooks: