Ubuntu操作系统通过saltstack安装docker

Quick Start

Docker是一个开源的应用容器引擎,基于Go语言并遵从Apache2.0协议开源,源代码部署在GitHub上,现已被广泛使用。
常规情况下,Docker作为基础组件打在os的镜像里,对于后期加入管理的主机可通过saltstack进行批量安装。

新建docker的state.sls文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
repository:
pkg.installed:
- pkgs:
- apt-transport-https
- curl
- ca-certificates
- software-properties-common
- refresh: True

docker-ce:
pkgrepo.managed:
- name: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{grains['oscodename']}} stable
- key_url: https://download.docker.com/linux/ubuntu/gpg
- refresh_db: true
- require:
- pkg: repository
- require_in:
- pkg: docker-ce

pkg.installed:
- name: docker-ce
- refresh: True

测试执行结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
salt '*' state.sls docker test=True
minion1:
----------
ID: repository
Function: pkg.installed
Result: None
Comment: The following packages would be installed/updated: software-properties-common, apt-transport-https
Started: 23:30:54.553191
Duration: 3797.25 ms
Changes:
----------
ID: docker-ce
Function: pkgrepo.managed
Name: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
Result: None
Comment: Package repo 'deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable' will be configured. This may cause pkg states to behave differently than stated if this action is repeated without test=True, due to the differences in the configured repositories.
Started: 23:30:58.355189
Duration: 114.982 ms
Changes:
----------
ID: docker-ce
Function: pkg.installed
Result: None
Comment: The following packages would be installed/updated: docker-ce
Started: 23:30:58.470868
Duration: 56.745 ms
Changes:

Summary for minion1
------------
Succeeded: 3 (unchanged=3)
Failed: 0
------------
Total states run: 3
Total run time: 3.969 s