Redhat 安装 FPM 打包工具

入职新公司,工作需要做运维开发,在为服务器安装 telegraf agent 过程中,大多数工作消耗在配置文件的编写上,由于不同环境的配置文件区别不大,只需将数据库,中间件的地址做下变更,另外不同类型的服务器,配置文件也有相同的部分,故考虑用 Python 脚本生成配置文件,并将此配置文件打包与 telegraf 一起打包发布,用 Ansible 统一部署,以前一周的工作量,现在一小时就能完成,而且还大大减少了错误发生的几率。说说 FPM 安装的问题:

安装FPM支持模块ruby

1
2
3
4
5
6
7
8
9
10
11
12
[root@MONITOR01 ~]# yum install ruby-devel gcc make rpm-build rubygems

Loaded plugins: fastestmirror
puppet-Centos7.1 | 3.6 kB 00:00:00
Loading mirror speeds from cached hostfile

No package ruby-devel available.
No package gcc available.
Package 1:make-3.82-23.el7.x86_64 already installed and latest version
No package rpm-build available.
Package rubygems-2.0.14.1-34.el7_6.noarch already installed and latest version
Nothing to do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
更换 yum 源
[root@MONITOR01 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

--2019-03-01 17:43:40-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)...
121.22.229.230, 121.22.229.235, 121.22.229.231, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|121.22.229.230|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[===============================================================>] 2,523 --.-K/s in 0s

2019-03-01 17:43:46 (188 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

重新安装

1
2
3
4
5
6
清理缓存
sudo yum clean all
生成新缓存
sudo yum makecache
重新安装
# yum install ruby-devel gcc make rpm-build rubygems

安装fpm

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
更新 rubygem 源
[root@MONITOR01 ~]# gem sources --add http://mirrors.aliyun.com/rubygems/ --remove https://rubygems.org/

[root@MONITOR01 ~]# gem install fpm

Fetching: cabin-0.9.0.gem (100%)
Successfully installed cabin-0.9.0
Fetching: backports-3.12.0.gem (100%)
Successfully installed backports-3.12.0
Fetching: arr-pm-0.0.10.gem (100%)
Successfully installed arr-pm-0.0.10
Fetching: clamp-1.0.1.gem (100%)
Successfully installed clamp-1.0.1
Fetching: ffi-1.10.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.10.0
Fetching: childprocess-0.9.0.gem (100%)
Successfully installed childprocess-0.9.0
Fetching: io-like-0.3.0.gem (100%)
Successfully installed io-like-0.3.0
Fetching: ruby-xz-0.2.3.gem (100%)
Successfully installed ruby-xz-0.2.3
Fetching: stud-0.0.23.gem (100%)
Successfully installed stud-0.0.23
Fetching: mustache-0.99.8.gem (100%)
Successfully installed mustache-0.99.8
Fetching: insist-1.0.0.gem (100%)
Successfully installed insist-1.0.0
Fetching: dotenv-2.7.1.gem (100%)
Successfully installed dotenv-2.7.1
Fetching: pleaserun-0.0.30.gem (100%)
Successfully installed pleaserun-0.0.30
Fetching: fpm-1.11.0.gem (100%)
Successfully installed fpm-1.11.0
Parsing documentation for cabin-0.9.0
Installing ri documentation for cabin-0.9.0
Parsing documentation for backports-3.12.0
Installing ri documentation for backports-3.12.0
Parsing documentation for arr-pm-0.0.10
Installing ri documentation for arr-pm-0.0.10
Parsing documentation for clamp-1.0.1
Installing ri documentation for clamp-1.0.1
Parsing documentation for ffi-1.10.0
Installing ri documentation for ffi-1.10.0
Parsing documentation for childprocess-0.9.0
Installing ri documentation for childprocess-0.9.0
Parsing documentation for io-like-0.3.0
Installing ri documentation for io-like-0.3.0
Parsing documentation for ruby-xz-0.2.3
Installing ri documentation for ruby-xz-0.2.3
Parsing documentation for stud-0.0.23
Installing ri documentation for stud-0.0.23
Parsing documentation for mustache-0.99.8
Installing ri documentation for mustache-0.99.8
Parsing documentation for insist-1.0.0
Installing ri documentation for insist-1.0.0
Parsing documentation for dotenv-2.7.1
Installing ri documentation for dotenv-2.7.1
Parsing documentation for pleaserun-0.0.30
Installing ri documentation for pleaserun-0.0.30
Parsing documentation for fpm-1.11.0
Installing ri documentation for fpm-1.11.0
14 gems installed

检查

1
2
[root@MONITOR01 ~]# fpm --version
1.11.0