まずはApacheをインストールするためのPlaybookを作成する。InstallHttpd.ymlとかにしておく。
--- - hosts : ChildServers gather_facts: no tasks: - name : install httpd by dnf dnf: name=httpd state=latest register: results - debug : var=results |
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV PLAY [ChildServers] *********************************************************** TASK: [ install httpd by dnf] ************************************************** failed: [172.16.33.174] => { "failed" : true } msg: `python-dnf` is not installed, but it is required for the Ansible dnf module. FATAL: all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @ /root/InstallHttpd .retry 172.16.33.174 : ok=0 changed=0 unreachable=0 failed=1 |
# dnf -y install python-dnf メタデータの期限切れの確認は、0:36:24 前の Sat Feb 13 01:30:53 2016 に実施しました。 依存性が解決されました。 ======================================================================================================================== Package アーキテクチャ バージョン リポジトリ 容量 ======================================================================================================================== インストール: pygpgme x86_64 0.3-13.fc23 fedora 77 k pyliblzma x86_64 0.5.3-14.fc23 fedora 54 k python-hawkey x86_64 0.6.2-3.fc23 updates 78 k python-iniparse noarch 0.4-16.fc23 fedora 45 k python-libcomps x86_64 0.1.7-1.fc23 fedora 47 k python-librepo x86_64 1.7.16-2.fc23 fedora 53 k python2-dnf noarch 1.1.6-2.fc23 updates 449 k rpm-python x86_64 4.13.0-0.rc1.11.fc23 updates 100 k トランザクションの要約 ======================================================================================================================== インストール 8 パッケージ 総ダウンロード容量: 902 k インストール済み容量: 3.0 M パッケージをダウンロードしています: (1 /8 ): pyliblzma-0.5.3-14.fc23.x86_64.rpm 145 kB /s | 54 kB 00:00 (2 /8 ): python2-dnf-1.1.6-2.fc23.noarch.rpm 1.1 MB /s | 449 kB 00:00 (3 /8 ): pygpgme-0.3-13.fc23.x86_64.rpm 187 kB /s | 77 kB 00:00 (4 /8 ): python-iniparse-0.4-16.fc23.noarch.rpm 474 kB /s | 45 kB 00:00 (5 /8 ): python-libcomps-0.1.7-1.fc23.x86_64.rpm 543 kB /s | 47 kB 00:00 (6 /8 ): python-librepo-1.7.16-2.fc23.x86_64.rpm 555 kB /s | 53 kB 00:00 (7 /8 ): python-hawkey-0.6.2-3.fc23.x86_64.rpm 977 kB /s | 78 kB 00:00 (8 /8 ): rpm-python-4.13.0-0.rc1.11.fc23.x86_64.rpm 1.2 MB /s | 100 kB 00:00 ------------------------------------------------------------------------------------------------------------------------ 合計 399 kB /s | 902 kB 00:02 トランザクションの確認を実行中... トランザクションの確認に成功しました。 トランザクションのテストを実行中... トランザクションのテストに成功しました。 トランザクションを実行中... インストール : rpm-python-4.13.0-0.rc1.11.fc23.x86_64 1 /8 インストール : python-hawkey-0.6.2-3.fc23.x86_64 2 /8 インストール : python-librepo-1.7.16-2.fc23.x86_64 3 /8 インストール : python-libcomps-0.1.7-1.fc23.x86_64 4 /8 インストール : python-iniparse-0.4-16.fc23.noarch 5 /8 インストール : pyliblzma-0.5.3-14.fc23.x86_64 6 /8 インストール : pygpgme-0.3-13.fc23.x86_64 7 /8 インストール : python2-dnf-1.1.6-2.fc23.noarch 8 /8 検証中 : python2-dnf-1.1.6-2.fc23.noarch 1 /8 検証中 : pygpgme-0.3-13.fc23.x86_64 2 /8 検証中 : pyliblzma-0.5.3-14.fc23.x86_64 3 /8 検証中 : python-iniparse-0.4-16.fc23.noarch 4 /8 検証中 : python-libcomps-0.1.7-1.fc23.x86_64 5 /8 検証中 : python-librepo-1.7.16-2.fc23.x86_64 6 /8 検証中 : python-hawkey-0.6.2-3.fc23.x86_64 7 /8 検証中 : rpm-python-4.13.0-0.rc1.11.fc23.x86_64 8 /8 インストール: pygpgme.x86_64 0.3-13.fc23 pyliblzma.x86_64 0.5.3-14.fc23 python-hawkey.x86_64 0.6.2-3.fc23 python-iniparse.noarch 0.4-16.fc23 python-libcomps.x86_64 0.1.7-1.fc23 python-librepo.x86_64 1.7.16-2.fc23 python2-dnf.noarch 1.1.6-2.fc23 rpm-python.x86_64 4.13.0-0.rc1.11.fc23 完了しました! |
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV PLAY [ChildServers] *********************************************************** TASK: [ install httpd by dnf] ************************************************** changed: [172.16.33.174] TASK: [debug var=results] ***************************************************** ok: [172.16.33.174] => { "var" : { "results" : { "changed" : true , "invocation" : { "module_args" : "name=httpd state=latest" , "module_complex_args" : {}, "module_name" : "dnf" }, "results" : [ "Installed: httpd-2.4.18-1.fc23.x86_64" , "Installed: mailcap-2.1.45-1.fc23.noarch" , "Installed: httpd-tools-2.4.18-1.fc23.x86_64" , "Installed: httpd-filesystem-2.4.18-1.fc23.noarch" , "Installed: apr-1.5.2-2.fc23.x86_64" , "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch" , "Installed: apr-util-1.5.4-2.fc23.x86_64" ] } } } PLAY RECAP ******************************************************************** 172.16.33.174 : ok=2 changed=1 unreachable=0 failed=0 |
うまくいったみたいだ。インストール先のChildOneSVでhttpdが自動起動に登録されているかを見る。
# systemctl list-unit-files | grep httpd httpd.service disabled httpd.socket disabled |
--- - hosts : ChildServers gather_facts: no tasks: - name : install httpd by dnf dnf: name=httpd state=latest register: results - debug : var=results - name : Auto Start httpd daemon service: name=httpd enabled=yes register: results - debug : var=results |
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV PLAY [ChildServers] *********************************************************** TASK: [ install httpd by dnf] ************************************************** changed: [172.16.33.174] TASK: [debug var=results] ***************************************************** ok: [172.16.33.174] => { "var" : { "results" : { "changed" : true , "invocation" : { "module_args" : "name=httpd state=latest" , "module_complex_args" : {}, "module_name" : "dnf" }, "results" : [ "Installed: httpd-2.4.18-1.fc23.x86_64" , "Installed: mailcap-2.1.45-1.fc23.noarch" , "Installed: httpd-tools-2.4.18-1.fc23.x86_64" , "Installed: httpd-filesystem-2.4.18-1.fc23.noarch" , "Installed: apr-1.5.2-2.fc23.x86_64" , "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch" , "Installed: apr-util-1.5.4-2.fc23.x86_64" ] } } } TASK: [Auto Start httpd daemon] *********************************************** changed: [172.16.33.174] TASK: [debug var=results] ***************************************************** ok: [172.16.33.174] => { "var" : { "results" : { "changed" : true , "enabled" : true , "invocation" : { "module_args" : "name=httpd enabled=yes" , "module_complex_args" : {}, "module_name" : "service" }, "name" : "httpd" } } } PLAY RECAP ******************************************************************** 172.16.33.174 : ok=4 changed=2 unreachable=0 failed=0 |
# systemctl list-unit-files | grep httpd httpd.service enabled httpd.socket disabled |
# ps -aef | grep httpd root 2162 1195 0 03:07 pts /0 00:00:00 grep --color=auto httpd |
--- - hosts : ChildServers gather_facts: no tasks: - name : install httpd by dnf dnf: name=httpd state=latest register: results - debug : var=results - name : Auto Start httpd daemon service: name=httpd state=started enabled=yes register: results - debug : var=results |
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV PLAY [ChildServers] *********************************************************** TASK: [ install httpd by dnf] ************************************************** changed: [172.16.33.174] TASK: [debug var=results] ***************************************************** ok: [172.16.33.174] => { "var" : { "results" : { "changed" : true , "invocation" : { "module_args" : "name=httpd state=latest" , "module_complex_args" : {}, "module_name" : "dnf" }, "results" : [ "Installed: httpd-2.4.18-1.fc23.x86_64" , "Installed: mailcap-2.1.45-1.fc23.noarch" , "Installed: httpd-tools-2.4.18-1.fc23.x86_64" , "Installed: httpd-filesystem-2.4.18-1.fc23.noarch" , "Installed: apr-1.5.2-2.fc23.x86_64" , "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch" , "Installed: apr-util-1.5.4-2.fc23.x86_64" ] } } } TASK: [Auto Start httpd daemon] *********************************************** changed: [172.16.33.174] TASK: [debug var=results] ***************************************************** ok: [172.16.33.174] => { "var" : { "results" : { "changed" : true , "enabled" : true , "invocation" : { "module_args" : "name=httpd state=started enabled=yes" , "module_complex_args" : {}, "module_name" : "service" }, "name" : "httpd" , "state" : "started" } } } PLAY RECAP ******************************************************************** 172.16.33.174 : ok=4 changed=2 unreachable=0 failed=0 |
# ps -aef | grep httpd root 2283 1 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 2285 2283 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 2286 2283 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 2290 2283 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 2292 2283 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 2294 2283 0 03:13 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND root 2297 1195 0 03:13 pts /0 00:00:00 grep --color=auto httpd |