newbie nagios client deployment problem

27 views
Skip to first unread message

Thomas Steele

unread,
Jun 13, 2016, 1:39:44 PM6/13/16
to Ansible Project
I'm trying to get a playbook that will download, untar, configure and make nagios client on a rhel7 server. So far the download and untar are working perfectly, but the configure and make commands are not running properly. Going to the server itself and running ./configure and make works perfectly. Any help is greatly appreciated.

playbook:
---
- name: new nagios client install
  hosts: ewok
  remote_user: fscan
  become: yes
  become_method: sudo
  become_user: root
  roles:
    - nagios

role:
---
- name: create Nagios user
  user: name=nagios shell=/bin/bash comment="nagios user"

- name: install gcc
  yum: state=present name=gcc

- name: install xinetd
  yum: state=present name=xinetd

- name: install openssl-devel
  yum: state=present name=openssl-devel

- name: create install directory
  file: path=/tmp/download/ state=directory

- name: transfer and untar nagios-plugins
  unarchive: src=files/nagios-plugins-2.0.3.tar.gz dest=/tmp/download mode=0755

- name: ownership managment
  file: path=/tmp/download/ state=directory recurse=yes owner=fscan group=fscan

- name: configure nagios
  command: /tmp/download/nagios-plugins-2.0.3/configure

- name: make files
  command: /tmp/download/nagios-plugins-2.0.3 make;make install


- name: change permissions
  file: path=/usr/local/nagios recurse=yes owner=nagios group=nagios



fscan@browns:/etc/ansible/playbooks/tsteele ansible-playbook tsteele_nagios_client_install.yml

PLAY [new nagios client install] ***********************************************

TASK [setup] *******************************************************************
ok: [ewok]

TASK [nagios : create Nagios user] *********************************************
ok: [ewok]

TASK [nagios : install gcc] ****************************************************
ok: [ewok]

TASK [nagios : install xinetd] *************************************************
ok: [ewok]

TASK [nagios : install openssl-devel] ******************************************
ok: [ewok]

TASK [nagios : create install directory] ***************************************
changed: [ewok]

TASK [nagios : transfer and untar nagios-plugins] ******************************
changed: [ewok]

TASK [nagios : ownership managment] ********************************************
changed: [ewok]

TASK [nagios : configure nagios] ***********************************************
changed: [ewok]

TASK [nagios : make files] *****************************************************
fatal: [ewok]: FAILED! => {"changed": false, "cmd": "/tmp/download/nagios-plugins-2.0.3 'make;make' install", "failed": true, "msg": "[Errno 13] Permission denied", "rc": 13}

NO MORE HOSTS LEFT *************************************************************
        to retry, use: --limit @tsteele_nagios_client_install.retry

PLAY RECAP *********************************************************************
ewok                       : ok=10   changed=5    unreachable=0    failed=1

Kai Stian Olstad

unread,
Jun 13, 2016, 2:04:39 PM6/13/16
to ansible...@googlegroups.com
On 13. juni 2016 19:33, Thomas Steele wrote:
> I'm trying to get a playbook that will download, untar, configure and make
> nagios client on a rhel7 server. So far the download and untar are working
> perfectly, but the configure and make commands are not running properly.
> Going to the server itself and running ./configure and make works
> perfectly. Any help is greatly appreciated.
>

Use chdir


> - name: configure nagios
> command: /tmp/download/nagios-plugins-2.0.3/configure

- name: configure nagios
command: ./configure
args:
chdir: /tmp/download/nagios-plugins-2.0.3


> - name: make files
> command: /tmp/download/nagios-plugins-2.0.3 make;make install

The semicolon is a shell operation, command doesn't support that. You
will have to use shell, split it in two or use with_items.

And maybe something like this will work:
- name: configure, make and make install nagios
command: "{{ item }}"
args:
chdir: /tmp/download/nagios-plugins-2.0.3
with_items:
- ./configure
- make
- make install

--
Kai Stian Olstad

Thomas Steele

unread,
Jun 13, 2016, 2:54:49 PM6/13/16
to Ansible Project
That worked! Thanks so much!
Reply all
Reply to author
Forward
0 new messages