aboutsummaryrefslogtreecommitdiff
path: root/example.yml
blob: 3b9ff2f1653f5eeee5c0f9430a06c8b8c87f8373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
- hosts: localhost
  tasks:
  - name: Create a host in Foreman
    foremanhost:
      name: foobar
      hostgroup: Medium/jenkins/blue
      compute_resource: libvirt
      state: present
      image: Jessie
      api_user: foreman
      api_password: changeme
      api_url: https://127.0.0.1
      ssl_verify: False
    register: result

  - debug:
      msg: Got "{{ result }}"

  - name: Shutdown a host in Foreman
    foremanhost:
      state: poweredOff
      name: foobar.example.com
    register: shutdow_result

  - assert:
      that:
        - shutdown_result.changed == false
        - shutdown_result.power_state == 'poweredOff'

  - name: Delete a host in Foreman
    foremanhost:
      name: foobar.example.com
      state: absent
      api_user: foreman
      api_password: changeme
      api_url: https://127.0.0.1
      ssl_verify: False