Ubuntu操作系统通过saltstack安装nginx

Quick Start

新建nginx的state.sls文件

1
2
3
4
5
6
7
8
9
10
nginx:
pkgrepo.managed:
- name: deb http://nginx.org/packages/ubuntu/ {{grains['oscodename']}} nginx
- key_url: http://nginx.org/keys/nginx_signing.key
- refresh_db: true
- require_in:
- pkg: nginx

pkg.installed:
- name: nginx

测试运行结果

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
salt '*' state.sls nginx test=True
minion1:
----------
ID: nginx
Function: pkgrepo.managed
Name: deb http://nginx.org/packages/ubuntu/ xenial nginx
Result: None
Comment: Package repo 'deb http://nginx.org/packages/ubuntu/ xenial nginx' 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:49:18.727125
Duration: 96.173 ms
Changes:
----------
ID: nginx
Function: pkg.installed
Result: None
Comment: The following packages would be installed/updated: nginx
Started: 23:49:22.886030
Duration: 3786.682 ms
Changes:

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