Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.11.1 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

Automating OCSinventory install with RPMs

Hello community,

I want to automate the installation of ocsinventory with Ansible, using installation from RPMs on a single server CentOS 7_9.
So I've followed the doc over and over: http://wiki.ocsinventory-ng.org/03.Basic-documentation/Setting-up-a-OCS-Inventory-Server-with-rpm/

I have different concerns,
Step by step, what I do is :
1) Install packages
2) configure database
3) configure ocs
4) secure ocs

Step 1) & 2) are fine. Here are the packages that I have for OCS :

rpm -qa | grep ocs

ocsinventory-agent-2.6.0-2.1.el7.x86_64

ocsinventory-server-2.8.1-1.el7.ocs.noarch

ocsinventory-2.8.1-1.el7.ocs.noarch

ocsinventory-reports-2.8.1-1.el7.ocs.noarch
 

Problems starting at step 3), when I want to launch the install.php by requesting the url : http://my_server_name/ocsreports/install.php
I give it below infos :

nameInstall OCS database
  ansible.builtin.uri:
    url"http://{{ target }}/ocsreports/install.php"
    methodPOST
    body:
      name"{{ ocs_server_mysql_user }}"
      password"{{ ocs_server_mysql_root_password }}"
      database"{{ ocs_server_mysql_db }}"
      host"{{ ocs_server_mysql_bind_address }}"
      port"{{ ocs_server_mysql_port_listener }}"

The task is ok but nothing seems to happen on the server side.

TASK [ds-profile-ocs_server : Install OCS database] ****************************************************************************************************************************************************************************************

Thursday 06 May 2021  10:15:05 +0200 (0:00:04.690)       0:00:32.192 **********

ok:

Whereas when I do fil manually on the web page MySQL login, password, database, hostname, port... it's ok I can go to the next step.
I also tried different way mentioned in doc by doing a shell command :

nameLaunch db install using command line
  ansible.builtin.shellmysql -f -hlocalhost -uroot -p"{{ ocs_server_mysql_root_password }}" "{{ ocs_server_mysql_db }}" < "{{ ocs_server_ocs_reports_dir }}"/files/ocsbase.sql >log.log


This is working and create tables in database.
But when I go on URL : http://my_server_name/ocsreports/
I still have the formular page as for http://my_server_name/ocsreports/install.php
Whereas I should have login page ?
Even by restarting httpd.

Also, when doing the secure part, I observed that deleting the file install.php will result in an error 500 on the server.
How to avoid this when it is specifically said to remove this file ?

I would really appreciate some help and any feedback.

Additional Infos on important directories/files =>

ll /etc/httpd/conf

total 28

-rw-r--r-- 1 root root 11967 May  5 17:00 httpd.conf

-rw-r--r-- 1 root root 13064 Oct  9  2020 magic

ll /etc/httpd/conf.d/

total 56

-rw-r--r-- 1 root root  2926 Oct  9  2020 autoindex.conf

-rw-rw-r-- 1 root root  1008 Dec  8  2017 ocsinventory-lang-reports.conf

-rw-r--r-- 1 root root  4521 Apr  3 00:59 ocsinventory-reports.conf

-rw-r--r-- 1 root root   691 Apr  3 00:59 ocsinventory-restapi.conf

-rw-r--r-- 1 root root 14597 Apr  3 00:59 ocsinventory-server.conf

-rw-r--r-- 1 root root  1752 Nov  4  2019 perl.conf

-rw-r--r-- 1 root root  1252 Apr 27 16:40 php.conf

-rw-r--r-- 1 root root   366 Oct  9  2020 README

-rw-r--r-- 1 root root  1252 Oct  9  2020 userdir.conf

-rw-r--r-- 1 root root   516 Oct  9  2020 welcome.conf

 ll /usr/share/ocsinventory-reports/ocsreports/

total 524

drwxrwxr-x  2 root apache     31 May  4 12:18 ajax

-rwxrwxr-x  1 root apache   1127 Sep 11  2020 ajax.php

drwxrwxr-x  6 root apache     67 May  4 12:18 backend

-rwxrwxr-x  1 root apache  27607 Sep 11  2020 Changes

-rwxrwxr-x  1 root apache    430 Sep 11  2020 composer.json

-rwxrwxr-x  1 root apache   6731 Sep 11  2020 composer.lock

-rwxrwxr-x  1 root apache   1027 Sep 11  2020 Contributors

drwxrwxr-x  2 root apache     46 May  4 12:18 crontab

drwxrwxr-x  2 root apache    270 May  4 12:18 css

-rw-rw----  1 root apache    281 May  5 16:59 dbconfig.inc.php

-rwxrwxr-x  1 root apache 370070 Sep 11  2020 favicon.ico

drwxrwxr-x  4 root apache     88 May  4 12:18 files

-r-xr-xr-x  1 root apache    936 May  5 16:59 http_functions.php

-r-xr-xr-x  1 root apache    707 May  5 16:59 http_get.php

-r-xr-xr-x  1 root apache   1326 May  5 16:59 http_put.php

drwxrwxr-x  2 root apache   4096 May  4 12:18 image

-rwxrwxr-x  1 root apache   1697 Sep 11  2020 index.php

-rwxrwxr-x  1 root apache  13184 May  5 17:09 install.php

-rwxrwxr-x  1 root apache  20892 Sep 11  2020 ipdiscover-util.pl

drwxrwxr-x  2 root apache    274 May  4 12:18 js

drwxrwxr-x  9 root apache    135 May  4 12:18 libraries

-rwxrwxr-x  1 root apache  18046 Sep 11  2020 LICENSE

-rwxrwxr-x  1 root apache   4528 Sep 11  2020 README.md

drwxrwxr-x 26 root apache   4096 May  4 12:18 require

drwxrwxr-x  2 root apache     48 May  4 12:18 templates

drwxrwxr-x  3 root apache     17 May  4 12:18 themes

drwxrwxr-x  2 root apache    148 May  4 12:18 tools

-rwxrwxr-x  1 root apache   4829 Sep 11  2020 update.php

-rwxrwxr-x  1 root apache   5848 Apr  3 00:59 var.php

drwxrwxr-x  6 root apache     89 May  4 12:18 vendor

in OCS Inventory NG server for Unix by (260 points)

2 Answers

0 votes
Hi,

You could use this https://github.com/OCSInventory-NG/Ansible-Role-For-UnixAgent as example for creating your ocs server ansible role.

Regards

Frank
by (88.5k points)
0 votes

Hello,

Thanks.
I've found the solution to my problem it's fine now. I got a fully automated install for ocsinventory-server.

Posting the install task here for whom would find it useful :
 

nameInstall OCS database
  ansible.builtin.uri:
    url"http://{{ target }}/ocsreports/"
    methodPOST
    body:
      name"{{ ocs_server_mysql_user }}"
      pass"{{ ocs_server_mysql_root_password }}"
      database"{{ ocs_server_mysql_db }}"
      host"{{ ocs_server_mysql_bind_address }}"
      port"{{ ocs_server_mysql_port_listener }}"
      enablessl"{{ ocs_server_db_ssl_enabled }}"
      sslmode"{{ ocs_server_ssl_mode }}"
      sslkey"{{ ocs_server_certs_folder }}/{{ ansible_hostname }}.{{ ocs_server_domain }}.key"
      sslcert"{{ ocs_server_certs_folder }}/{{ ansible_hostname }}.{{ ocs_server_domain }}.cer"
      cacert"{{ ocs_server_ca_cert }}"
    body_formatform-urlencoded
    status_code200
    return_contentyes
  no_logtrue
  registerocs_server_database_install
  whenocs_server_action == 'install'
  tagsocs_server_database_install

by (260 points)
 
Powered by Question2Answer
...