Install nagios on a remote maschine | execute a command like you would be connected via ssh

Hello Everybody,

I am relatively new to Ansible and working on Student’s project with it, so please be patient.

As the subject says I would like install nagios on a remote instance. If I connect via ssh everything works just fine, but of course I would like to automate that. In general I need to translate these commands in an ansible-playbook:

cd /tmp
wget http://assets.nagios.com/downloads/nagiosxi/xi-latest.tar.gz
tar xzf xi-latest.tar.gz
cd nagiosxi

./fullinstall

This is how my playbook looks like right now. The Copy part ist just because I copy a modified “fullinstall” file without the promt for “Do you really want to install”. Everything works fine so far but the last task.

  • name: Install nagios server
    hosts: nagioss
    become: yes
    become_method: sudo

tasks:

  • name: download
    get_url:
    url: https://assets.nagios.com/downloads/nagiosxi/xi-latest.tar.gz
    dest: /tmp
  • name: Unzip
    unarchive:
    src: /tmp/xi-latest.tar.gz
    dest: /tmp
    remote_src: yes
  • name: copy modified script
    copy:
    src: NAGIOS/fullinstall
    dest: /tmp/nagiosxi/fullinstall
  • name: Install
    command: ./fullinstall
    args:
    chdir: /tmp/nagiosxi

I am receiving this error:


On the remote server is CentOS 6 installed.

Kind regards,
Jan

Another way that would work for me would be to simply install a script by this playbook:

  • name: Install nagios server
    hosts: nagioss
    become: yes
    become_method: sudo

tasks:

  • name: copy modified script
    copy:
    src: templates/install.sh
    dest: /tmp/install.sh
  • name: Install
    command: chmod +x install.sh
    args:
    chdir: /tmp
  • name: Install
    command: ./install.sh
    args:
    chdir: /tmp

But I am receiving this error message:

This is an Ansible core question. Try asking on https://groups.google.com/forum/#!forum/ansible-project