commit 06745b14c856bea8d384aeb0385fd8bf8cce5c1a Author: Gardais Jérémy Date: Mon Sep 10 11:33:08 2018 +0200 Install fusioninventory-agent packages and dep diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d49fcc2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ + +## v1.0 + +### Features +* Install dependent packages for fusioninventory-agent. +* Install fusioninventory-agent package from URL. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8867a46 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# FusionInventory + +1. [Overview](#overview) +2. [Role Variables](#role-variables) +3. [Example Playbook](#example-playbook) +4. [Configuration](#configuration) +5. [Development](#development) +6. [License](#license) +7. [Author Information](#author-information) + +## Overview + +A role to manage FusionInventory agent installation and configuration. + +## Role Variables + +* **fusioninventory__agent_version** : The version of Fusioninventory agent to install [default : `2.4-2`]. +* **fusioninventory__agent_depend_packages** : List of dependent packages to install. +* **fusioninventory__agent_package_url** : The URL used to download deb package for fusioninventory-agent [default : `http://debian.fusioninventory.org/downloads/fusioninventory-agent_{{ fusioninventory__agent_version }}_all.deb`]. +* **fusioninventory__agent_deploy_state** : What is the desired state which this role should achieve [default : `present`]. +* **fusioninventory__agent_service_name** : The service name to manage [default : `fusioninventory-agent`]. +* **fusioninventory__agent_service_manage** : If the fusioninventory agent service should be managed [default : `True`]. + +## Example Playbook + +* Use defaults vars : + +``` yaml +- hosts: mynode.DOMAIN + roles: + - role: ipr-cnrs.fusioninventory + tags: ['role::fusioninventory', 'ipr', inventory'] +``` + +* Install fusioninventory-agent from repository (unavailable in Debian Stretch) : + +``` yaml +- hosts: mynode.DOMAIN + roles: + - role: ipr-cnrs.fusioninventory + fusioninventory__agent_package_url: '' + tags: ['role::fusioninventory', 'ipr', inventory'] +``` + +## Configuration + +This role will : +* Install needed dependent packages of fusioninventory-agent. +* Install fusioninventory-agent package from official project package/URL. + +## Development + +This source code comes from our [Gogs instance][fusioninventory source] and the [Github repo][fusioninventory github] exist just to be able to send the role to Ansible Galaxy… + +But feel free to send issue/PR here :) + +Thanks to this [hook][gogs to github hook], Github automatically got updates from our [Gogs instance][fusioninventory source] :) + +## License + +[WTFPL][wtfpl website] + +## Author Information + +Jérémy Gardais +* Source : [on IPR's Gogs][fusioninventory source] +* [IPR][ipr website] (Institut de Physique de Rennes) + +[gogs to github hook]: https://stackoverflow.com/a/21998477 +[fusioninventory source]: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.fusioninventory +[fusioninventory github]: https://github.com/ipr-cnrs/fusioninventory +[wtfpl website]: http://www.wtfpl.net/about/ +[ipr website]: https://ipr.univ-rennes1.fr/ diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..9516beb --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,78 @@ +--- +# .. vim: foldmarker=[[[,]]]:foldmethod=marker + +# ipr-cnrs.fusioninventory default variables [[[ +# ====================================== + +# Packages and installation [[[ +# ----------------------------- + +# .. envvar:: fusioninventory__agent_version [[[ +# +# The version of Fusioninventory agent to install. +# +fusioninventory__agent_version: '2.4-2' + # ]]] +# .. envvar:: fusioninventory__agent_depend_packages [[[ +# +# List of dependent packages to install. +fusioninventory__agent_depend_packages: + - 'dmidecode' + - 'hwdata' + - 'hdparm' + - 'libuniversal-require-perl' + - 'libwww-perl' + - 'libparse-edid-perl' + - 'libproc-daemon-perl' + - 'libfile-which-perl' + - 'libhttp-daemon-perl' + - 'libxml-treepp-perl' + - 'libyaml-perl' + - 'libnet-cups-perl' + - 'libnet-ip-perl' + - 'libdigest-sha-perl' + - 'libsocket-getaddrinfo-perl' + - 'libtext-template-perl' + # ]]] +# .. envvar:: fusioninventory__agent_package_url [[[ +# +# The URL used to download deb package for fusioninventory-agent. +# +# See the official documentation for more informations : +# http://fusioninventory.org/documentation/agent/installation/linux/deb.html +# +fusioninventory__agent_package_url: 'http://debian.fusioninventory.org/downloads/fusioninventory-agent_{{ fusioninventory__agent_version }}_all.deb' + # ]]] +# .. envvar:: fusioninventory__agent_deploy_state [[[ +# +# What is the desired state which this role should achieve ? Possible options : +# +# ``present`` +# Default. Ensure that fusioninventory agent is installed and configured as requested. +# +# ``absent`` +# Ensure that fusioninventory agent is uninstalled and it's configuration is removed. +# +fusioninventory__agent_deploy_state: 'present' + # ]]] +# .. envvar:: fusioninventory__agent_service_name [[[ +# +# The service name to manage. +# +fusioninventory__agent_service_name: 'fusioninventory-agent' + + # ]]] +# .. envvar:: fusioninventory__agent_service_manage [[[ +# +# If the fusioninventory agent service should be managed ? Possible options : +# +# ``True`` +# Default. The service is started and enabled. +# +# ``False`` +# The service is disabled from startup. +# +fusioninventory__agent_service_manage: True + + # ]]] + # ]]] diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..d3c37db --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,15 @@ +galaxy_info: + author: "Jérémy Gardais" + description: "Manage FusionInventory Agent" + license: WTFPL + company: IPR + issue_tracker_url: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.fusioninventory-agent/issues + min_ansible_version: 2.6 + platforms: + - name: Debian + versions: + - stretch + galaxy_tags: + - agent + - fusion + - inventory diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..bbdeb51 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,26 @@ +--- +# .. vim: foldmarker=[[[,]]]:foldmethod=marker +# +# tasks file for fusioninventory + +# Manage agent package [[[1 +- name: Ensure fusioninventory agent package from URL + apt: + deb: '{{ fusioninventory__agent_package_url | d(omit) }}' + state: '{{ "present" if (fusioninventory__agent_deploy_state == "present") else "absent" }}' + when: fusioninventory__agent_package_url != "" + +- name: Ensure fusioninventory agent package from REPOS + package: + name: 'fusioninventory-agent' + state: '{{ "present" if (fusioninventory__agent_deploy_state == "present") else "absent" }}' + when: fusioninventory__agent_package_url == "" + +# Manage dependent packages [[[1 +- name: Ensure dependent packages are in there desired state + package: + name: '{{ item }}' + state: '{{ "present" if (fusioninventory__agent_deploy_state == "present") else "absent" }}' + with_flattened: + - '{{ fusioninventory__agent_depend_packages }}' + diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..d18580b --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost \ No newline at end of file diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..44452eb --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - fusioninventory