/foreman-ansible-modules

Repository for Ansible modules that communicate with Foreman and plugin APIs

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Foreman Ansible Modules Build Status

This repository contains Ansible modules for interacting with a Foreman server API and various plugin APIs such as Katello.

Goals

The intent of this repository is to be a place that community members can develop or contribute modules. The goals of this repository are:

How To Use The Repository

The following is an example of how you could use this repository in your own environment. Let's assume you have a directory of playbooks and roles in a git repository for your infrastructure named infra:

infra/
├── playbooks
└── roles

First, clone this repository into infra/:

cd infra/
git clone https://github.com/theforeman/foreman-ansible-modules.git

Note the ansible.cfg file cloned with foreman-ansible-modules. The ansible.cfg needs to be in your current directory when you run ansible or ansible-playbook. You can copy it to another location or add it to your current ansible configuration; make sure to update the relative paths to the foreman-ansible-module modules and module_utils if you do so.

Now your playbooks and roles should have access to the modules and module_utils contained in the repository for use, testing, or development of new modules.

How to test modules in this repository

To test, you need a running instance of Foreman, probably with Katello (use forklift if unsure). Also you need to run test-setup and update test/test_playbooks/server_vars.yml:

make test-setup
vi test/test_playbooks/server_vars.yml # point to your Foreman instance

To run the tests:

make test # all tests
make test_product  # single test
make test TEST="-k 'organzation or product'"  # select tests by expression (see `pytest -h`)

The tests are run against prerecorded server-responses. You can (re-)record the cassettes for a specific test with

make record_<test name>

See also Guidedeline to writing tests.

How to debug modules in this repository

Set up debugging using ansible's test-module

make debug-setup

Debug with ansible's test-module

make debug MODULE=<module name>

# Example: debug the katello_content_view module
$ make debug MODULE=katello_content_view
./.tmp/ansible/hacking/test-module -m modules/katello_content_view.py -a @test/data/content-view.json -D /usr/lib64/python2.7/pdb.py
...

You can set a number of environment variables besides MODULE to configure make. Check the Makefile for more configuration options.

Modules List

This is a list of modules currently in the repository (please add to the list if adding a module).

Entity Modules

  • foreman_global_parameter: create and maintain global parameters
  • foreman_operating_system: create and maintain operating systems
  • foreman_os_default_template: create and maintain the association of default templates to operating systems
  • foreman_organization: create and maintain organizations
  • foreman_location: create and maintain locations
  • foreman_ptable: create and maintain partition templates
  • foreman_provisioning_template: create and maintain provisioning templates
  • foreman_compute_resource: create and maintain compute resources
  • foreman_domain: create and maintain domains
  • foreman_job_template: create and maintain job templates and associated template inputs
  • foreman_setting: set and reset settings
  • katello_product: create and maintain products
  • katello_repository: create and maintain repositories
  • katello_content_view: create and maintain content views
  • katello_sync_plan: create and maintain sync plans
  • katello_activation_key: create and maintain activation keys
  • redhat_manifest: create and maintain manifests

Action Modules

  • katello_sync: sync Katello repositories and products
  • katello_upload: upload files, rpms, etc. to repositories
  • katello_content_view_publish: publish Katello content views
  • katello_manifest: upload and Manage Katello manifests