2016年2月9日火曜日

Ansibleを使ってFedora23にサーバを構築していく〜準備編(1)

このエントリーをはてなブックマークに追加
サーバの自動構築。なんという夢の響きだろうか。あのめんどくさい作業から解放されるためなんだったら何でもやろう。という事でAnsibleを使ってやってみることにした。Chefはなんかめんどくさそうなイメージが果てしなくあったので何となくAnsibleを選んだ。


今回はVMWare Fusionを使って試すことにした。まずは準備としてFedora23 Server EditionのMinimalインストールする。そしてすぐにシャットダウンし、この.vmwareファイルをオリジナルファイル(以下、OriginalVM)として保存。それをコピーしAnsible用のマシン(以下、AnsibleVM)として構築していく。

以降、操作するのは全てAnsibleVMの方なので注意すること。

ターミナルの方がやりやすいのでiTerm2でAnsibleVMへ接続し、iTermでログの取得(Shell→Log→Start)をしておく。この方が後々役にたつはず。

$ ssh root@xxx.xxx.xxx.xxx
dnfでできるだけ早いミラーサイトからパッケージを取ってくるために/etc/dnf/dnf.confに追記。
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
fastestmirror=true
ここでdnfでアップデート。
# dnf update
メタデータの期限切れの確認は、0:51:03 前の Mon Feb  8 03:24:13 2016 に実施しました。
依存性が解決されました。
========================================================================================================================
 パッケージ                            アーキテクチャ   バージョン                              リポジトリ         容量
========================================================================================================================
インストール中:
 kernel                                x86_64           4.3.4-300.fc23                          updates            52 k
 kernel-core                           x86_64           4.3.4-300.fc23                          updates            20 M
 kernel-modules                        x86_64           4.3.4-300.fc23                          updates            18 M
 libsecret                             x86_64           0.18.3-1.fc23                           fedora            156 k
アップグレード中:
 GeoIP-GeoLite-data                    noarch           2015.12-1.fc23                          updates           367 k
 NetworkManager                        x86_64           1:1.0.10-2.fc23                         updates           1.9 M
 NetworkManager-libnm                  x86_64           1:1.0.10-2.fc23                         updates           481 k
 audit                                 x86_64           2.4.5-1.fc23                            updates           243 k
 audit-libs                            x86_64           2.4.5-1.fc23                            updates            95 k
 avahi-autoipd                         x86_64           0.6.32-0.4.rc.fc23                      updates            31 k
 avahi-libs                            x86_64           0.6.32-0.4.rc.fc23                      updates            62 k
 bash                                  x86_64           4.3.42-3.fc23                           updates           1.4 M
 bind99-libs                           x86_64           9.9.8-2.P3.fc23                         updates           655 k
 bind99-license                        noarch           9.9.8-2.P3.fc23                         updates            12 k
 bzip2-libs                            x86_64           1.0.6-19.fc23                           updates            45 k
 ca-certificates                       noarch           2015.2.6-1.0.fc23                       updates           432 k
 chkconfig                             x86_64           1.7-1.fc23                              updates           179 k
 coreutils                             x86_64           8.24-5.fc23                             updates           2.8 M
 crypto-policies                       noarch           20151104-1.gitf1cba5f.fc23              updates            30 k
 curl                                  x86_64           7.43.0-5.fc23                           updates           285 k
 dbus                                  x86_64           1:1.10.6-1.fc23                         updates           244 k
 dbus-glib                             x86_64           0.106-1.fc23                            updates           121 k
 dbus-libs                             x86_64           1:1.10.6-1.fc23                         updates           173 k
 deltarpm                              x86_64           3.6-13.fc23                             updates            88 k
 device-mapper                         x86_64           1.02.109-2.fc23                         updates           292 k
 device-mapper-event                   x86_64           1.02.109-2.fc23                         updates           206 k
 device-mapper-event-libs              x86_64           1.02.109-2.fc23                         updates           209 k
 device-mapper-libs                    x86_64           1.02.109-2.fc23                         updates           346 k
 dhcp-client                           x86_64           12:4.3.3-8.P1.fc23                      updates           300 k
 dhcp-common                           noarch           12:4.3.3-8.P1.fc23                      updates           194 k
 dhcp-libs                             x86_64           12:4.3.3-8.P1.fc23                      updates           138 k
 dnf                                   noarch           1.1.6-2.fc23                            updates           290 k
 dnf-conf                              noarch           1.1.6-2.fc23                            updates            91 k
 dnf-plugins-core                      noarch           0.1.16-1.fc23                           updates            37 k
 dnf-yum                               noarch           1.1.6-2.fc23                            updates            85 k
 dnsmasq                               x86_64           2.75-3.fc23                             updates           294 k
 dracut                                x86_64           043-63.git20151211.fc23                 updates           324 k
 dracut-config-rescue                  x86_64           043-63.git20151211.fc23                 updates            45 k
 ebtables                              x86_64           2.0.10-18.fc23                          updates           126 k
 elfutils-default-yama-scope           noarch           0.165-2.fc23                            updates            38 k
 elfutils-libelf                       x86_64           0.165-2.fc23                            updates           213 k
 elfutils-libs                         x86_64           0.165-2.fc23                            updates           272 k
 emacs-filesystem                      noarch           1:24.5-7.fc23                           updates            65 k
 file                                  x86_64           5.22-6.fc23                             updates            66 k
 file-libs                             x86_64           5.22-6.fc23                             updates           423 k
 findutils                             x86_64           1:4.5.16-1.fc23                         updates           563 k
 gettext                               x86_64           0.19.7-3.fc23                           updates           1.0 M
 gettext-libs                          x86_64           0.19.7-3.fc23                           updates           504 k
 glib2                                 x86_64           2.46.2-1.fc23                           updates           2.3 M
 glibc                                 x86_64           2.22-7.fc23                             updates           3.6 M
 glibc-common                          x86_64           2.22-7.fc23                             updates            11 M
 gnupg2                                x86_64           2.1.9-1.fc23                            updates           1.8 M
 gnutls                                x86_64           3.4.8-1.fc23                            updates           657 k
 grep                                  x86_64           2.22-6.fc23                             updates           275 k
 grub2                                 x86_64           1:2.02-0.25.fc23                        updates           3.8 M
 grub2-tools                           x86_64           1:2.02-0.25.fc23                        updates           7.1 M
 gsettings-desktop-schemas             x86_64           3.18.1-1.fc23                           updates           518 k
 hawkey                                x86_64           0.6.2-3.fc23                            updates            92 k
 hwdata                                noarch           0.285-2.fc23                            updates           1.4 M
 initscripts                           x86_64           9.65-1.fc23                             updates           406 k
 ipcalc                                x86_64           0.1.4-2.fc23                            updates            31 k
 iproute                               x86_64           4.1.1-3.fc23                            updates           598 k
 iputils                               x86_64           20140519-7.fc23                         updates           161 k
 kbd                                   x86_64           2.0.2-8.fc23                            updates           379 k
 kbd-legacy                            noarch           2.0.2-8.fc23                            updates           476 k
 kbd-misc                              noarch           2.0.2-8.fc23                            updates           1.4 M
 kmod                                  x86_64           22-2.fc23                               updates           112 k
 kmod-libs                             x86_64           22-2.fc23                               updates            61 k
 krb5-libs                             x86_64           1.14-7.fc23                             updates           839 k
 libarchive                            x86_64           3.1.2-14.fc23                           updates           322 k
 libassuan                             x86_64           2.4.2-1.fc23                            updates            75 k
 libblkid                              x86_64           2.27.1-2.fc23                           updates           180 k
 libcurl                               x86_64           7.43.0-5.fc23                           updates           256 k
 libdrm                                x86_64           2.4.66-1.fc23                           updates           144 k
 libfdisk                              x86_64           2.27.1-2.fc23                           updates           221 k
 libgcc                                x86_64           5.3.1-2.fc23                            updates            88 k
 libgomp                               x86_64           5.3.1-2.fc23                            updates           152 k
 libgpg-error                          x86_64           1.21-1.fc23                             updates           154 k
 libmount                              x86_64           2.27.1-2.fc23                           updates           197 k
 libnghttp2                            x86_64           1.6.0-1.fc23                            updates            65 k
 libnl3                                x86_64           3.2.27-1.fc23                           updates           265 k
 libpng                                x86_64           2:1.6.19-2.fc23                         updates           118 k
 libreport-filesystem                  x86_64           2.6.4-1.fc23                            updates            46 k
 libsmartcols                          x86_64           2.27.1-2.fc23                           updates           139 k
 libsolv                               x86_64           0.6.14-7.fc23                           updates           346 k
 libsoup                               x86_64           2.52.2-1.fc23                           updates           385 k
 libssh2                               x86_64           1.6.0-3.fc23                            updates           147 k
 libstdc++                             x86_64           5.3.1-2.fc23                            updates           425 k
 libuuid                               x86_64           2.27.1-2.fc23                           updates            79 k
 libxml2                               x86_64           2.9.3-2.fc23                            updates           684 k
 linux-firmware                        noarch           20151214-60.gitbbe4917c.fc23            updates            32 M
 lua                                   x86_64           5.3.2-2.fc23                            updates           294 k
 lvm2                                  x86_64           2.02.132-2.fc23                         updates           1.0 M
 lvm2-libs                             x86_64           2.02.132-2.fc23                         updates           927 k
 nettle                                x86_64           3.2-1.fc23                              updates           306 k
 nspr                                  x86_64           4.10.10-2.fc23                          updates           134 k
 nss                                   x86_64           3.21.0-1.1.fc23                         updates           860 k
 nss-softokn                           x86_64           3.21.0-1.1.fc23                         updates           314 k
 nss-softokn-freebl                    x86_64           3.21.0-1.1.fc23                         updates           207 k
 nss-sysinit                           x86_64           3.21.0-1.1.fc23                         updates            56 k
 nss-tools                             x86_64           3.21.0-1.1.fc23                         updates           493 k
 nss-util                              x86_64           3.21.0-1.0.fc23                         updates            81 k
 openssh                               x86_64           7.1p2-3.fc23                            updates           430 k
 openssh-clients                       x86_64           7.1p2-3.fc23                            updates           635 k
 openssh-server                        x86_64           7.1p2-3.fc23                            updates           461 k
 openssl                               x86_64           1:1.0.2f-1.fc23                         updates           496 k
 openssl-libs                          x86_64           1:1.0.2f-1.fc23                         updates           1.2 M
 os-prober                             x86_64           1.70-1.fc23                             updates            48 k
 p11-kit                               x86_64           0.23.2-1.fc23                           updates           151 k
 p11-kit-trust                         x86_64           0.23.2-1.fc23                           updates           131 k
 pcre                                  x86_64           8.38-4.fc23                             updates           495 k
 pinentry                              x86_64           0.9.6-4.fc23                            updates            81 k
 plymouth                              x86_64           0.8.9-11.2013.08.14.fc23                updates           113 k
 plymouth-core-libs                    x86_64           0.8.9-11.2013.08.14.fc23                updates           100 k
 plymouth-scripts                      x86_64           0.8.9-11.2013.08.14.fc23                updates            38 k
 policycoreutils                       x86_64           2.4-18.fc23                             updates           922 k
 python3-dbus                          x86_64           1.2.0-12.fc23                           updates           121 k
 python3-dnf                           noarch           1.1.6-2.fc23                            updates           454 k
 python3-dnf-plugins-core              noarch           0.1.16-1.fc23                           updates            80 k
 python3-gobject-base                  x86_64           3.18.2-1.fc23                           updates           296 k
 python3-hawkey                        x86_64           0.6.2-3.fc23                            updates            73 k
 python3-sssdconfig                    noarch           1.13.3-3.fc23                           updates           100 k
 rpm                                   x86_64           4.13.0-0.rc1.11.fc23                    updates           510 k
 rpm-build-libs                        x86_64           4.13.0-0.rc1.11.fc23                    updates           116 k
 rpm-libs                              x86_64           4.13.0-0.rc1.11.fc23                    updates           294 k
 rpm-plugin-selinux                    x86_64           4.13.0-0.rc1.11.fc23                    updates            51 k
 rpm-plugin-systemd-inhibit            x86_64           4.13.0-0.rc1.11.fc23                    updates            51 k
 rpm-python3                           x86_64           4.13.0-0.rc1.11.fc23                    updates           100 k
 selinux-policy                        noarch           3.13.1-158.4.fc23                       updates           435 k
 selinux-policy-targeted               noarch           3.13.1-158.4.fc23                       updates           5.6 M
 sqlite                                x86_64           3.10.2-1.fc23                           updates           476 k
 sudo                                  x86_64           1.8.15-1.fc23                           updates           691 k
 systemd                               x86_64           222-14.fc23                             updates           6.3 M
 systemd-libs                          x86_64           222-14.fc23                             updates           474 k
 tzdata                                noarch           2016a-1.fc23                            updates           409 k
 util-linux                            x86_64           2.27.1-2.fc23                           updates           2.1 M
 xkeyboard-config                      noarch           2.16-2.fc23                             updates           761 k

トランザクションの要約
========================================================================================================================
インストール      4 Packages
アップグレード  133 Packages

総ダウンロード容量: 156 M

これでパッケージのアップデートは完了したので、Ansibleをdnfでインストールすることにした。いつもは最新版が欲しいのでソースから入れる派なんだけど、Fedoraだしその辺はそれなりに新しいパッケージが入るだろうという事で。

# dnf install ansible
メタデータの期限切れの確認は、0:33:38 前の Tue Feb  9 00:39:37 2016 に実施しました。
依存性が解決されました。
========================================================================================================================
 Package                           アーキテクチャ         バージョン                      リポジトリ               容量
========================================================================================================================
インストール:
 PyYAML                            x86_64                 3.11-11.fc23                    updates                 168 k
 ansible                           noarch                 1.9.4-1.fc23                    updates                 1.7 M
 libtomcrypt                       x86_64                 1.17-25.fc23                    fedora                  229 k
 libtommath                        x86_64                 0.42.0-6.fc23                   fedora                   39 k
 libyaml                           x86_64                 0.1.6-7.fc23                    fedora                   58 k
 python                            x86_64                 2.7.10-8.fc23                   fedora                   94 k
 python-babel                      noarch                 1.3-8.fc23                      fedora                  2.5 M
 python-crypto                     x86_64                 2.6.1-7.fc23                    fedora                  468 k
 python-ecdsa                      noarch                 0.11-4.fc23                     fedora                   73 k
 python-httplib2                   noarch                 0.9.1-2.fc23                    fedora                  119 k
 python-jinja2                     noarch                 2.8-2.fc23                      fedora                  464 k
 python-keyczar                    noarch                 0.71c-5.fc23                    fedora                  222 k
 python-libs                       x86_64                 2.7.10-8.fc23                   fedora                  5.8 M
 python-markupsafe                 x86_64                 0.23-7.fc23                     fedora                   35 k
 python-paramiko                   noarch                 1.15.2-3.fc23                   fedora                  254 k
 python-pip                        noarch                 7.1.0-1.fc23                    fedora                  1.5 M
 python-pyasn1                     noarch                 0.1.8-1.fc23                    fedora                  104 k
 python-setuptools                 noarch                 18.0.1-2.fc23                   fedora                  425 k
 python-six                        noarch                 1.9.0-3.fc23                    fedora                   34 k
 pytz                              noarch                 2015.4-1.fc23                   fedora                   60 k
 sshpass                           x86_64                 1.05-8.fc23                     fedora                   25 k

トランザクションの要約
========================================================================================================================
インストール  21 パッケージ

総ダウンロード容量: 14 M
インストール済み容量: 58 M

確認してみる。
# ansible --version
ansible 1.9.4

できた、できた。

0 件のコメント:

コメントを投稿