Skip to content

Commit

Permalink
feat: init foreman collection
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Jul 31, 2022
0 parents commit 4f98883
Show file tree
Hide file tree
Showing 10 changed files with 839 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore(ci): "
24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
release:
types:
- published

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Prepare version
id: prep
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo ::set-output name=version::${VERSION}
- name: Deploy the collection
uses: artis3n/ansible_galaxy_collection@v2
with:
api_key: ${{ secrets.GALAXY_API_KEY }}
galaxy_version: ${{ steps.prep.outputs.version }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint and Test

on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Lint with flake8
run: |
pip install flake8
flake8 . --count --show-source --statistics
- name: Lint with black
run: |
pip install --pre black
black .
- name: Lint with ansible-lint
uses: ansible-community/ansible-lint-action@v6
with:
targets: |
roles/locations
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ansible Collection - radiorabe.foreman

Contains foreman roles and playbooks.

## Roles

* [`locations`](https://github.com/radiorabe/ansible-collection-foreman/tree/main/roles/locations)

## License

This collection is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
16 changes: 16 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace: radiorabe
name: foreman
version: 0.0.0
readme: README.md
authors:
- Lucas Bickel <@hairmare>
description: Roles managing Foreman (mainly what's missing from FAM)
license_file: LICENSE
tags:
- radiorabe
- foreman
dependencies: {}
repository: https://github.com/radiorabe/ansible-collection-foreman
documentation: https://github.com/radiorabe/ansible-collection-foreman/blob/main/README.md
homepage: hhttps://github.com/radiorabe/ansible-collection-foreman
issues: https://github.com/radiorabe/ansible-collection-foreman/issues
1 change: 1 addition & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requires_ansible: ">=2.11,<2.14"
48 changes: 48 additions & 0 deletions roles/locations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Ansible Role - radiorabe.formman.locations

This role creates and manages locations in Foreman.

## Requirements

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.

## Role Variables

This role supports the [FAM Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables).

The main data structure for this role is the list of `foreman_locations`. Each `location` requires the following fields:

- `name`: The name of the location.

The following fields are optional in the sense that the server will use default values when they are omitted:

- `parent`: Title of a parent Location for nesting.
- `organizations`: List of organizations the location should be assigned to.
- `state`: The state of the location. Can be `present` or `absent`.

## Dependencies

The `radiorabe.foreman.locations` role depends on modules from the [`theforeman.foreman`](https://galaxy.ansible.com/theforeman/foreman) collection.

## Example Playbooks

```yaml
- name: add location to foreman
hosts: localhost
gather_facts: false
roles:
- role: radiorabe.foreman.locations
vars:
foreman_server_url: https://foreman.example.com
foreman_username: admin
foreman_password: changeme
foreman_organizations:
- name: Randweg
origanizations:
- RaBe
state: present
```
## License
This role is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
17 changes: 17 additions & 0 deletions roles/locations/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
galaxy_info:
author: RaBe IT-Reaktion
description: Creates and manages locations in Foreman.
issue_tracker_url: https://github.com/radiorabe/ansible-collection-foreman/issues
license: AGPL-3.0-only
min_ansible_version: 2.9
platforms:
- name: EL
versions:
- all
- name: Fedora
version:
- all
galaxy_tags:
- radiorabe
- foreman
dependencies: []
16 changes: 16 additions & 0 deletions roles/locations/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Add locations
theforeman.foreman.location:
# common args
server_url: "{{ foreman_server_url | default(omit) }}"
username: "{{ foreman_username | default(omit) }}"
password: "{{ foreman_password | default(omit) }}"
validate_certs: "{{ foreman_validate_certs | default(omit) }}"
# location args
name: "{{ foreman_locations_item.name }}"
parent: "{{ foreman_locations_item.parent | default(omit) }}"
organizations: "{{ foreman_locations_item.organizations | default(omit) }}"
state: "{{ foreman_locations_item.state | default(omit) }}"
loop: "{{ foreman_locations | default([]) }}"
loop_control:
loop_var: foreman_locations_item

0 comments on commit 4f98883

Please sign in to comment.