An Ansible module for adding, editing, and removing Stacki hosts.
The module takes these parameters:
`name` - The name of the host to manage
`appliance` - The appliance used for the host
`box` - The box used for the host
`comment` - Freeform text to attach to the host
`environment` - Environment to assign the host
`groups` - List of groups to add or remove the host from. Each item has parameters:
`name` - The name of the group
`state` - If present, then a host will be added to this group.If absent, then the host will be removed from this group.
`installaction` - The install boot action for the host
`interfaces` - List of network interfaces for the host. Each item has parameters:
`channel` - Channel for this interface
`default` - Is the interface is the default for the hosts
`interface` - Device for this interface
`ip` - IP address for this interface
`name` - Logical name for this interface
`network` - Network attached to this interface
`mac` - Hardware MAC address for this interface
`module` - Device module for this interface
`options` - Module options for this interface
`vlan` - The VLAN ID for this interface
`state` - If present, then an interface will be added to the host, if needed, and options updates. If absent, then the interface will be removed from the host. If update_mac, then the interface device is used to update the mac. If update_interface, then the mac is used to update the interface device. Note: The interface device and mac are both used to match for updating an existing interface.
`osaction` - The os boot action for the host
`rack` - By convention, the number of the rack where the host is located
`rank` - By convention, the position of the host in the rack
`state` - If present, then a host will be added (if needed) and options are set to match. If absent, then the host will be removed.
Example playbook:
```
---
- hosts: localhost
tasks:
- name: Add a host
stacki_host:
name: test-backend
appliance: backend
box: default
comment: "test host"
groups:
- name: test
installaction: console
interfaces:
- default: true
interface: eth0
ip: "10.10.10.10"
mac: "00:11:22:33:44:55"
rack: "10"
rank: "4"
register: result
- name: Add host output
debug:
var: result
- name: Modify a host
stacki_host:
name: test-backend
groups:
- name: test
state: absent
installaction: default
interfaces:
- interface: eth0
state: absent
- interface: eth1
ip: "10.10.2.1"
mac: "11:22:33:44:55:66"
rack: "0"
rank: "0"
register: result
- name: Modify host output
debug:
var: result
- name: Remove a host
stacki_host:
name: test-backend
state: absent
register: result
- name: Remove host output
debug:
var: result
```
Output of the debug commands, showing the structure of the data returned:
```
TASK [Add host output] **************************************************************************
ok: [localhost] => {
"result": {
"changed": true,
"failed": false
}
}
TASK [Modify host output] ***********************************************************************
ok: [localhost] => {
"result": {
"changed": true,
"failed": false
}
}
TASK [Remove host output] ***********************************************************************
ok: [localhost] => {
"result": {
"changed": true,
"failed": false
}
}
```