HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__pycache__/foreman.cpython-310.pyc
o

�N�g��
@spdZddlZzddlZdZWneydZYnwdddddddddd	�	Ze�e�Zd
Z	dd�Z
ddd�ZdS)a�
A module to pull data from Foreman via its API into the Pillar dictionary


Configuring the Foreman ext_pillar
==================================

Set the following Salt config to setup Foreman as external pillar source:

.. code-block:: yaml

  ext_pillar:
    - foreman:
        key: foreman # Nest results within this key
        only: ['hostgroup_name', 'parameters'] # Add only these keys to pillar

  foreman.url: https://example.com/foreman_api
  foreman.user: username # default is admin
  foreman.password: password # default is changeme

The following options are optional:

.. code-block:: yaml

  foreman.api: apiversion # default is 2 (1 is not supported yet)
  foreman.verifyssl: False # default is True
  foreman.certfile: /etc/ssl/certs/mycert.pem # default is None
  foreman.keyfile: /etc/ssl/private/mykey.pem # default is None
  foreman.cafile: /etc/ssl/certs/mycert.ca.pem # default is None
  foreman.lookup_parameters: True # default is True

An alternative would be to use the Foreman modules integrating Salt features
in the Smart Proxy and the webinterface.

Further information can be found on `GitHub <https://github.com/theforeman/foreman_salt>`_.

Module Documentation
====================
�NTFzhttp://foreman/apiZadminZchangeme�)	�foreman.url�foreman.user�foreman.password�foreman.api�foreman.verifyssl�foreman.certfile�foreman.keyfile�foreman.cafile�foreman.lookup_parametersZforemancCstsdStS)z6
    Only return if all the modules are available
    F)�HAS_REQUESTS�__virtualname__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/foreman.py�__virtual__FsrrcsLtd}td}td}td}td}td}	td}
td}td	}t�d
||�zb|dkr7t�d�t�d
dt|�di}
|rI|durI|}tj|d|||f|
||	|
fdd�}|���t�	d��|r�t
�}�dD]
}|�|d|di�qo|�d<|r��fdd�|D��Wnty�t�d�iYSw|r�|�i��S)z4
    Read pillar data from Foreman via its API.
    rrrrrrr	r
rz-Querying Foreman at %r for information for %rrzTForeman API v2 is supported only, please specifyversion 2 in your Salt master config�acceptzversion=z,application/jsonNz/hosts/�x)Zauth�headers�verify�cert�timeoutz)Raw response of the Foreman request is %rZall_parameters�name�value�
parameterscsi|]}|�vr|�|�qSrr)�.0�k��resultrr�
<dictcomp>�szext_pillar.<locals>.<dictcomp>z*Could not fetch host data via Foreman API:)
�__opts__�log�info�error�	Exception�str�requests�get�json�debug�dict�update�	exception)Z	minion_idZpillar�keyZonly�url�user�passwordZapir�certfile�keyfile�cafileZlookup_parametersrZrespr�paramrrr�
ext_pillarOsX�
��
�r4)Nr)�__doc__�loggingr%r�ImportErrorr�	getLogger�__name__r r
rr4rrrr�<module>s,(��