- Description
- Requirements
- Examples
- License
- [Author information](#author information)
Ansible library to configure Foreman and manage hosts.
With the current implementation it's possible to create, update and delete the following Foreman Resources
- Architectures
- Compute Attributes
- Compute Profiles
- Compute Resources
- Config Templates
- Domains
- Environments
- Hosts
- Hostgroups
- Locations (needs Katello)
- Medium
- Operatingsystems
- Operatingsystem default templates
- Organizations (need s Katello)
- Partition Tables
- Roles
- Smart Proxies
- Subnets
- Users
python-foreman >= 0.12.11 is required to be installed on the system where Ansible is started from.
ansible.cfg
has to contain path to modules and module_utils:
[default]
library = ansible-module-foreman
module_utils = ansible-module-foreman/module_utils
The following parameters are always required so the module knows how to connect to the Foreman API v2. They are replaced in the examples by three dots (...).
foreman_host: foreman.example.com
foreman_port: 443
foreman_user: admin
foreman_pass: password
- name: Ensure Architecture
foreman_architecture:
name: x86_64
state: present
foreman_host: foreman.example.com
foreman_port: 443
foreman_user: admin
foreman_pass: password
- name: Ensure Compute Profile
foreman_compute_profile:
name: 1-Small
foreman_host: foreman.example.com
foreman_port: 443
foreman_user: admin
foreman_pass: password
- name: Ensure Compute Resource
foreman_compute_resource:
name: VMwareCluster01
state: present
url: vsphere.example.com
provider: VMWare
user: ansible
password: secret
server: vsphere.example.com
...
This is an example to configure VMware vSphere attributes.
- name: Ensure Compute Attribute
foreman_compute_attribute:
compute_profile: 1-Small
compute_resource: VMwareCluster1
vm_attributes:
cluster: Cluster1
corespersocket: 1
cpus: 1
guest_id: otherGuest64
hardware_version: vmx-10
interfaces_attributes:
'0':
_delete: ''
network: network-40
type: VirtualVmxnet3
'1':
_delete: ''
network: network-40
type: VirtualVmxnet3
new_interfaces:
_delete: ''
network: network-40
type: VirtualVmxnet3
memory_mb: 1024
path: /Datacenters/DC01/vm/example
scsi_controller_type: ParaVirtualSCSIController
volumes_attributes:
'0':
_delete: ''
datastore: DS01
eager_zero: true
name: Hard disk
size_gb: 16
thin: true
new_volumes:
_delete: ''
datastore: DS01
eager_zero: true
name: Hard disk
size_gb: 16
thin: true
...
- name: Ensure Config Template
foreman_config_template:
name: CoreOS Cloud-config
locked: false
operatingsystems:
- CoreOS
template_file: files/coreos-cloud-config
snippet: true
state: present
...
- name: Ensure Config Template
foreman_config_template:
name: CoreOS Cloud-config
locked: false
operatingsystems:
- CoreOS
template: "Some content"
snippet: true
state: present
...
- name: Ensure Domain
foreman_domain:
name: example.com
state: present
...
- name: Ensure Environment
foreman_environment:
name: Production
state: present
...
- name: Ensure Host
foreman_host:
name: ansible-host-01
state: running
architecture: x86_64
domain: example.com
environment: production
medium: CoreOS
provision_method: build
root_pass: topsecret
- name: Ensure Host
foreman_host:
name: ansible-host-03
state: running
compute_resource: VMwareCluster01
hostgroup: Hostgroup01
image: CoreOS Image
provision_method: image
...
- name: Ensure Host
foreman_host:
name: ansible-host-02
state: running
compute_resource: VMwareCluster01
hostgroup: Hostgroup01
provision_method: build
...
To delete a host Foreman must know the FQDN. Use one of the following methods:
- name: Ensure absent host
foreman_host:
name: ansible-host-01
domain: example.com
state: absent
...
or
- name: Ensure absent host
foreman_host:
name: ansible-host-01.example.com
state: absent
...
- name: Ensure Host
foreman_host:
name: ansible-host-04
state: present
.
.
interfaces:
- ip: 10.11.12.123
mac: 00:21:f6:16:e4:2e
subnet: "Dev Network"
- ip: 10.11.12.124
mac: 00:21:f6:42:52:91
subnet: "Dev Network"
...
- name: Ensure Hostgroup
foreman_hostgroup:
name: Hostgroup01
architecture: x86_64
domain: example.com
environment: production
medium: CoreOS mirror
operatingsystem: CoreOS
partition_table: CoreOS Partition Table
subnet: example.com
state: present
...
- name: Ensure Location
foreman_location:
name: Location01
state: present
...
- name: Ensure Medium
foreman_medium:
name: CoreOS
path: http://$release.release.core-os.net
os_family: CoreOS
state: present
...
- name: Ensure Operatingsystem
foreman_operatingsystem:
name: CoreOS
major: 633
minor: 0.0
architectures:
- x86_64
media:
- CoreOS mirror
ptables:
- CoreOS default fake
state: present
...
- name: Ensure Operatingsystem default template
foreman_os_default_template:
operatingsystem: CoreOS
config_template: CoreOS PXELinux
template_kind: PXELinux
state: present
...
Works only if Katello is used
- name: Ensure Organization
foreman_organization:
name: MyOrganization
state: present
...
- name: Ensure partition table
foreman_ptable:
name: MyPartitionTable
layout: 'some layout'
os_family: CoreOS
state: present
...
- name: Ensure Role
foreman_role:
name: MyRole
state: present
- name: Ensure Smart Proxy
foreman_smart_proxy:
name: SmartProxy01
url: http://localhost:8443
state: present
...
- name: Ensure User
foreman_user:
login: MyUser
admin: false
auth: 'Internal'
firstname: Testing
lastname: User
mail: testing.user@example.com
password: topsecret
roles:
- Manager
- Viewer
state: present
Copyright 2015 Thomas Krahn
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.