Skip to content

Ansible Custom Module zoneadm_facts. Gathers facts about configured local zone on a SunOS/Oracle Solaris global zone by zoneadm

License

Notifications You must be signed in to change notification settings

NomakCooper/zoneadm_facts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Custom Module Oracle Solaris python license

zoneadm_facts ansible custom module

Gathers facts about configured local zone on a SunOS/Oracle Solaris global zone by zoneadm

Description :

zoneadm_facts is a custom module for ansible that creates an ansible_facts containing the list and details of configured local zones on a SunOS/Oracle Solaris global zone

Repo files:

├── /library                
│   └── zoneadm_facts.py  ##<-- python custom module
└── zoneadm_list.yml      ##<-- ansible playbook example

Requirements :

  • This module supports SunOS/Oracle Solaris only
  • The Local Zone info are gathered from the zoneadm command

Parameters :

  • no parameters are needed

Attributes :

Attribute Support Description
check_mode full Can run in check_mode and return changed status prediction without modifying target.
facts full Action returns an ansible_facts dictionary that will update existing host facts.

Examples :

Tasks

---
  # Gather local zone info
  - name: Gather facts configured local zone
    zoneadm_facts:

  # print all lz name at running STATE
  - name: Print all LZ at running STATE
    debug:
      msg: "{{ ansible_facts.zone_list  | selectattr('STATUS','equalto', 'running' ) | map(attribute='NAME') }}"

  # print lz STATUS by ID
  - name: Print STATUS of LZ ID 3
    debug:
      msg: "LZ ID 3 STATUS : {{ ansible_facts.zone_list  | selectattr('ID','equalto', '3' ) | map(attribute='STATUS') | first }}"

zone_list facts:

"ansible_facts": {
  "zone_list": [
    {
      "STATUS": "running",
      "NAME": "sol10lab",
      "IP": "shared",
      "BRAND": "solaris10",
      "PATH": "/zones/sol10lab",
      "ID": "3"
    }
  ]
},

debug output from example :

TASK [Print STATUS of LZ ID 3] *************************************************
ok: [global_zone_host] => {
    "msg": "LZ ID 3 STATUS : running"
}
TASK [Print all LZ at running STATE] *******************************************
ok: [global_zone_host] => {
    "msg": [
        "sol9lab",
        "sol10lab"
    ]
}

Returned Facts :

  • Facts returned by this module are added/updated in the hostvars host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Key Type Description Returned Sample
zone_list list / elements=string Configured local Zone list
ID string The local zone ID. always "10"
NAME string The local zone name, could match the hostname of the local zone always "sol11lab"
STATUS string The local zone status. running, installed, configured. always "running"
PATH string The local zone path. always "/zones/sol11lab"
BRAND string The local zone brand. native, solaris10 and more. always "native"
IP string The local zone IP or shared. always "shared"

SANITY TEST

  • Ansible sanity test is available in SANITY.md file

Integration

  1. Assuming you are in the root folder of your ansible project.

Specify a module path in your ansible configuration file.

$ vim ansible.cfg
[defaults]
...
library = ./library
...

Create the directory and copy the python modules into that directory

$ mkdir library
$ cp path/to/module library
  1. If you use Ansible AWX and have no way to edit the control node, you can add the /library directory to the same directory as the playbook .yml file
├── root repository
│   ├── playbooks
│   │    ├── /library                
│   │    │   └── zoneadm_facts.py  ##<-- python custom module
│   │    └── your_playbook.yml      ##<-- you playbook

About

Ansible Custom Module zoneadm_facts. Gathers facts about configured local zone on a SunOS/Oracle Solaris global zone by zoneadm

Topics

Resources

License

Stars

Watchers

Forks

Languages