{"id":857,"date":"2018-08-29T11:42:10","date_gmt":"2018-08-29T09:42:10","guid":{"rendered":"http:\/\/www.mythryll.com\/?p=857"},"modified":"2019-12-12T18:10:42","modified_gmt":"2019-12-12T16:10:42","slug":"ansible-playbook-for-upgrading-ubuntu-based-nagios-server-to-latest-version","status":"publish","type":"post","link":"https:\/\/www.mythryll.com\/?p=857","title":{"rendered":"Ansible Playbook for upgrading Ubuntu based Nagios Server to latest version"},"content":{"rendered":"<p>Hello. This is a typical Ansible playbook code to upgrade your Nagios Server to the latest version (4.4.2, announced August 2018).<br \/>\nIt has been tested with Ubuntu 16.04.4 LTS for the Nagios Server, OpenSuSE 42.3 and Ansible 2.6 for the Ansible server.<br \/>\nIt is presumed that you have previously installed Nagios using source code, preferably with a 4.x version (upgrading from 3.x is different).<br \/>\nIf you are new at this I suggest you go through the process manually at least once. Start here: <a href=\"https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/4\/en\/upgrading.html\">https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/4\/en\/upgrading.html<\/a> but be mindful because the process described there is too generic. Depending on what you needed to activate on your nagios server, you may need different options and additional steps.<br \/>\nIf you are not new at this, you can take the playbook and modify it to suit your needs.<br \/>\nI am in no way responsible if you damage your system by applying commands that were not suited for it. Backup your system first, or take a snapshot if you are using Vmware as a platform (remember to remove it later if everything goes well, vmware snapshots are not equivalent to backup!).<br \/>\nYou can replace nagiosserverhostname with yours, as it is declared in your ansible host files. Start here: <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/index.html\">https:\/\/docs.ansible.com\/ansible\/latest\/index.html <\/a><br \/>\nYou will need to know the basics of how to install Ansible, create a list of your servers and run the playbook.<br \/>\nI intend to polish my Full Nagios Core Installation guide (Core Server, Nagios Plugins, extra plugins, Nagios Graph etc) and publish it as well, and then create a Playbook for creating such an installation from scratch with Ansible. The last part is not ready yet. Perhaps I will get to update my notes for Ubuntu 18.04 LTS but as the season is picking up pace, I may have little time to spare for it. I will do my best.<br \/>\nI am sorry I can&#8217;t allow comments on this site, the spam is too much to handle. You can look me up on twitter and ask there.<br \/>\nThere you go, I hope you find it usefull!<br \/>\nDon&#8217;t forget, it&#8217;s YAML syntax so indents are important plus other things you can read when you learn about Ansible.<br \/>\nYannis.<\/p>\n<p><code>---<br \/>\n- hosts: nagiosserverhostname<br \/>\ntasks:<br \/>\n- name: get rid of old installation dir<br \/>\nfile:<br \/>\npath: \/tmp\/nagios<br \/>\nstate: absent<br \/>\n- name: get rid of old installation archive<br \/>\nfile:<br \/>\npath: \/tmp\/nagios.tar.gz<br \/>\nstate: absent<br \/>\n- name: download and uncompress<br \/>\nshell: cd \/tmp;rm nagios*.tar.gz;wget -O nagios.tar.gz https:\/\/github.com\/NagiosEnterprises\/nagioscore\/archive\/nagios-4.4.2.tar.gz;tar -zxf nagios.tar.gz;mv nagioscore-nagios-4.4.2 nagios<br \/>\n- name: change dir to \/tmp<br \/>\nshell: cd \/tmp\/nagios;.\/configure --with-command-group=nagcmd --with-mail=\/usr\/sbin\/sendmail --with-httpd-conf=\/etc\/apache2\/;make all;make install;make install-init<br \/>\n- name: check configs syntax<br \/>\nshell: \/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<br \/>\n- name: restart nagios service<br \/>\nservice:<br \/>\nname: nagios<br \/>\nstate: restarted<br \/>\n- name: get rid of old installation dir<br \/>\nfile:<br \/>\npath: \/tmp\/nagios<br \/>\nstate: absent<br \/>\n- name: get rid of old installation archive<br \/>\nfile:<br \/>\npath: \/tmp\/nagios.tar.gz<br \/>\nstate: absent<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Ansible to upgrade your Nagios Server<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,14,21],"tags":[40,31,35,41],"class_list":["post-857","post","type-post","status-publish","format-standard","hentry","category-automation","category-it","category-monitoring-tools","tag-ansible","tag-automation","tag-monitoring","tag-nagios"],"_links":{"self":[{"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/posts\/857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=857"}],"version-history":[{"count":3,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/www.mythryll.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mythryll.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}