INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
List installed pecl extensions.
CLI Example:
.. code-block:: bash
salt '*' pecl.list | def list_(channel=None):
'''
List installed pecl extensions.
CLI Example:
.. code-block:: bash
salt '*' pecl.list
'''
pecl_channel_pat = re.compile('^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)')
pecls = {}
command = 'list'
if channel:
command = '{0} -c {1}'.format(command, _cmd... |
Get the details of a published repository.
:param str name: The distribution name of the published repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param str endpoint: The publishing endpoint.
:param str prefix: The prefix for publishing.
:return: A d... | def get_published(name, config_path=_DEFAULT_CONFIG_PATH, endpoint='', prefix=None):
'''
Get the details of a published repository.
:param str name: The distribution name of the published repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param str endpo... |
Ensure GPG public key is present in keychain
name
The unique name or keyid for the GPG public key.
keys
The keyId or keyIds to add to the GPG keychain.
user
Add GPG keys to the specified user's keychain
keyserver
The keyserver to retrieve the keys from.
gnupghome... | def present(name,
keys=None,
user=None,
keyserver=None,
gnupghome=None,
trust=None,
**kwargs):
'''
Ensure GPG public key is present in keychain
name
The unique name or keyid for the GPG public key.
keys
The keyId o... |
Sets domain to use custom DNS servers.
returns True if the custom nameservers were set successfully
sld
SLD of the domain name
tld
TLD of the domain name
nameservers
array of strings List of nameservers to be associated with this domain
CLI Example:
.. code-block::... | def set_custom(sld, tld, nameservers):
'''
Sets domain to use custom DNS servers.
returns True if the custom nameservers were set successfully
sld
SLD of the domain name
tld
TLD of the domain name
nameservers
array of strings List of nameservers to be associated with... |
Sets domain to use namecheap default DNS servers. Required for free
services like Host record management, URL forwarding, email forwarding,
dynamic DNS and other value added services.
sld
SLD of the domain name
tld
TLD of the domain name
Returns ``True`` if the domain was successf... | def set_default(sld, tld):
'''
Sets domain to use namecheap default DNS servers. Required for free
services like Host record management, URL forwarding, email forwarding,
dynamic DNS and other value added services.
sld
SLD of the domain name
tld
TLD of the domain name
Retu... |
Validate that the configuration file exists and is readable.
:param str config_path: The path to the configuration file for the aptly instance.
:return: None
:rtype: None | def _validate_config(config_path):
'''
Validate that the configuration file exists and is readable.
:param str config_path: The path to the configuration file for the aptly instance.
:return: None
:rtype: None
'''
log.debug('Checking configuration file: %s', config_path)
if not os.pat... |
Parse the output of an aptly show command.
:param str cmd_ret: The text of the command output that needs to be parsed.
:return: A dictionary containing the configuration data.
:rtype: dict | def _parse_show_output(cmd_ret):
'''
Parse the output of an aptly show command.
:param str cmd_ret: The text of the command output that needs to be parsed.
:return: A dictionary containing the configuration data.
:rtype: dict
'''
parsed_data = dict()
list_key = None
for line in cm... |
Get a list of all the published repositories.
:param str config_path: The path to the configuration file for the aptly instance.
:return: A list of the published repositories.
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' aptly.list_published | def list_published(config_path=_DEFAULT_CONFIG_PATH):
'''
Get a list of all the published repositories.
:param str config_path: The path to the configuration file for the aptly instance.
:return: A list of the published repositories.
:rtype: list
CLI Example:
.. code-block:: bash
... |
List all trails
Returns list of trails
CLI Example:
.. code-block:: yaml
policies:
- {...}
- {...} | def list(region=None, key=None, keyid=None, profile=None):
'''
List all trails
Returns list of trails
CLI Example:
.. code-block:: yaml
policies:
- {...}
- {...}
'''
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
t... |
Check if any minions have connected or dropped.
Send a message to the client if they have. | def process_presence_events(self, event_data, token, opts):
'''
Check if any minions have connected or dropped.
Send a message to the client if they have.
'''
tag = event_data['tag']
event_info = event_data['data']
minions_detected = event_info['present']
... |
Private function that returns an iterator over all CloudFront distributions.
The caller is responsible for all boto-related error handling.
name
(Optional) Only yield the distribution with the given name | def _list_distributions(
conn,
name=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Private function that returns an iterator over all CloudFront distributions.
The caller is responsible for all boto-related error handling.
name
(Optional) Only yield the di... |
Enforce a given set of tags on a CloudFront resource: adding, removing, or changing them
as necessary to ensure the resource's tags are exactly and only those specified.
Resource
The ARN of the affected CloudFront resource.
Tags
Dict of {'Tag': 'Value', ...} providing the tags to be enfor... | def enforce_tags(Resource, Tags, region=None, key=None, keyid=None, profile=None):
'''
Enforce a given set of tags on a CloudFront resource: adding, removing, or changing them
as necessary to ensure the resource's tags are exactly and only those specified.
Resource
The ARN of the affected Clou... |
Remove files belonging to a published repository. Aptly tries to remove as many files
belonging to this repository as possible.
:param str name: The distribution name of the published repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param str endpoint:... | def delete_published(name, config_path=_DEFAULT_CONFIG_PATH, endpoint='', prefix=None,
skip_cleanup=False, force=False):
'''
Remove files belonging to a published repository. Aptly tries to remove as many files
belonging to this repository as possible.
:param str name: The dist... |
Update properties for an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.update_image_properties name=image1 hw_scsi_model=virtio-scsi hw_disk_bus=scsi
salt '*' glanceng.update_image_properties name=0e4febc2a5ab4f2c8f374b054162506d min_ram=1024 | def update_image_properties(auth=None, **kwargs):
'''
Update properties for an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.update_image_properties name=image1 hw_scsi_model=virtio-scsi hw_disk_bus=scsi
salt '*' glanceng.update_image_properties name=0e4febc2a5ab4f2c8f374b... |
Set a CloudFront distribution to be disabled.
Id
Id of the distribution to update.
region
Region to connect to.
key
Secret key to use.
keyid
Access key to use.
profile
Dict, or pillar key pointing to a dict, containing AWS region/key/keyid.
CLI Examp... | def disable_distribution(region=None, key=None, keyid=None, profile=None, **kwargs):
'''
Set a CloudFront distribution to be disabled.
Id
Id of the distribution to update.
region
Region to connect to.
key
Secret key to use.
keyid
Access key to use.
profil... |
Remove a local package repository.
:param str name: The name of the local repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool force: Whether to remove the repository even if it is used as the source
of an existing snapshot.
:return: A bool... | def delete_repo(name, config_path=_DEFAULT_CONFIG_PATH, force=False):
'''
Remove a local package repository.
:param str name: The name of the local repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool force: Whether to remove the repository even... |
Get a splunk search
CLI Example:
splunk_search.get 'my search name' | def get(name, profile="splunk"):
'''
Get a splunk search
CLI Example:
splunk_search.get 'my search name'
'''
client = _get_splunk(profile)
search = None
# uglyness of splunk lib
try:
search = client.saved_searches[name]
except KeyError:
pass
return searc... |
Delete a cloudwatch alarm
CLI example to delete a queue::
salt myminion boto_cloudwatch.delete_alarm myalarm region=us-east-1 | def delete_alarm(name, region=None, key=None, keyid=None, profile=None):
'''
Delete a cloudwatch alarm
CLI example to delete a queue::
salt myminion boto_cloudwatch.delete_alarm myalarm region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
conn.de... |
Update the config (and optionally tags) for the CloudFront distribution with the given name.
name
Name of the CloudFront distribution
config
Configuration for the distribution
tags
Tags to associate with the distribution
region
Region to connect to
key
Se... | def update_distribution(
name,
config,
tags=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Update the config (and optionally tags) for the CloudFront distribution with the given name.
name
Name of the CloudFront distribution
config
Configurati... |
Ensure that an item is created
name
Irrelevant, not used
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
create
create command (create or set f.e., defaul... | def _item_present(name, item, item_id, item_type, show='show', create='create', extra_args=None, cibname=None):
'''
Ensure that an item is created
name
Irrelevant, not used
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item typ... |
Gets a list of DNS servers associated with the requested domain.
returns a dictionary of information about requested domain
sld
SLD of the domain name
tld
TLD of the domain name
CLI Example:
.. code-block:: bash
salt 'my-minion' namecheap_domains_dns.get_list sld tld | def get_list(sld, tld):
'''
Gets a list of DNS servers associated with the requested domain.
returns a dictionary of information about requested domain
sld
SLD of the domain name
tld
TLD of the domain name
CLI Example:
.. code-block:: bash
salt 'my-minion' namec... |
Display the profiling data in a table format. | def output(data, **kwargs):
'''
Display the profiling data in a table format.
'''
rows = _find_durations(data)
kwargs['opts'] = __opts__
kwargs['rows_key'] = 'rows'
kwargs['labels_key'] = 'labels'
to_show = {'labels': ['name', 'mod.fun', 'duration (ms)'],
'rows': rows... |
Convert string value to it's closest non-string analog, if possible.
:param dict value: The string value to attempt conversion on.
:return: The converted value.
:rtype: Union[bool, int, None, str] | def _convert_to_closest_type(value):
'''
Convert string value to it's closest non-string analog, if possible.
:param dict value: The string value to attempt conversion on.
:return: The converted value.
:rtype: Union[bool, int, None, str]
'''
value = salt.utils.stringutils.to_bool(value.str... |
Given a valid config, update a trail.
Returns {created: true} if the trail was created and returns
{created: False} if the trail was not created.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.update my_trail my_bucket | def update(Name,
S3BucketName, S3KeyPrefix=None,
SnsTopicName=None,
IncludeGlobalServiceEvents=None,
IsMultiRegionTrail=None,
EnableLogFileValidation=None,
CloudWatchLogsLogGroupArn=None,
CloudWatchLogsRoleArn=None,
KmsKeyId=None,
... |
Get the full path of a cached CIB-file with the name of the CIB | def _get_cibfile(cibname):
'''
Get the full path of a cached CIB-file with the name of the CIB
'''
cibfile = os.path.join(_get_cibpath(), '{0}.{1}'.format(cibname, 'cib'))
log.trace('cibfile: %s', cibfile)
return cibfile |
Get the full path of the file containing a checksum of a CIB-file with the name of the CIB | def _get_cibfile_cksum(cibname):
'''
Get the full path of the file containing a checksum of a CIB-file with the name of the CIB
'''
cibfile_cksum = '{0}.cksum'.format(_get_cibfile(cibname))
log.trace('cibfile_cksum: %s', cibfile_cksum)
return cibfile_cksum |
Search for images
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_search name=image1
salt '*' glanceng.image_search | def image_search(auth=None, **kwargs):
'''
Search for images
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_search name=image1
salt '*' glanceng.image_search
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwargs)
return cloud.search_images(**k... |
List images
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_list
salt '*' glanceng.image_list | def image_list(auth=None, **kwargs):
'''
List images
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_list
salt '*' glanceng.image_list
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwargs)
return cloud.list_images(**kwargs) |
Get the full path of a temporary CIB-file with the name of the CIB | def _get_cibfile_tmp(cibname):
'''
Get the full path of a temporary CIB-file with the name of the CIB
'''
cibfile_tmp = '{0}.tmp'.format(_get_cibfile(cibname))
log.trace('cibfile_tmp: %s', cibfile_tmp)
return cibfile_tmp |
Ensure that a fencing resource is created
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant, not used (recommended: pcs_stonith__created_{{stonith_id}})
stonith_id
name for the stonith resource... | def stonith_present(name, stonith_id, stonith_device_type, stonith_device_options=None, cibname=None):
'''
Ensure that a fencing resource is created
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevan... |
.. versionadded:: 0.17.0
Installs one or several pecl extensions.
pecls
The pecl extensions to install.
defaults
Use default answers for extensions such as pecl_http which ask
questions before installation. Without this option, the pecl.installed
state will hang indefinite... | def install(pecls, defaults=False, force=False, preferred_state='stable'):
'''
.. versionadded:: 0.17.0
Installs one or several pecl extensions.
pecls
The pecl extensions to install.
defaults
Use default answers for extensions such as pecl_http which ask
questions before i... |
Create a cloud vm with the given profile and instances, instances can be a
list or comma-delimited string
CLI Example:
.. code-block:: bash
salt-run cloud.profile prof=my-ec2 instances=node1,node2,node3 | def profile(prof=None, instances=None, opts=None, **kwargs):
'''
Create a cloud vm with the given profile and instances, instances can be a
list or comma-delimited string
CLI Example:
.. code-block:: bash
salt-run cloud.profile prof=my-ec2 instances=node1,node2,node3
'''
if prof i... |
Delete a splunk search
CLI Example:
splunk_search.delete 'my search name' | def delete(name, profile="splunk"):
'''
Delete a splunk search
CLI Example:
splunk_search.delete 'my search name'
'''
client = _get_splunk(profile)
try:
client.saved_searches.delete(name)
return True
except KeyError:
return None |
Remove a mirrored remote repository. By default, Package data is not removed.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool force: Whether to remove the mirror even if it is used as the source
... | def delete_mirror(name, config_path=_DEFAULT_CONFIG_PATH, force=False):
'''
Remove a mirrored remote repository. By default, Package data is not removed.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:pa... |
Return the connection status with the network device. | def alive(opts):
'''
Return the connection status with the network device.
'''
log.debug('Checking if %s is still alive', opts.get('id', ''))
if not netmiko_device['always_alive']:
return True
if ping() and initialized():
return netmiko_device['connection'].remote_conn.transport.... |
Write content to a file | def _file_write(path, content):
'''
Write content to a file
'''
with salt.utils.files.fopen(path, 'w+') as fp_:
fp_.write(salt.utils.stringutils.to_str(content))
fp_.close() |
Ensure that a resource is created
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant, not used (recommended: {{formulaname}}__resource_present_{{resource_id}})
resource_id
name for the resource
... | def resource_present(name, resource_id, resource_type, resource_options=None, cibname=None):
'''
Ensure that a resource is created
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant, not used (recom... |
Create a splunk search
CLI Example:
splunk_search.create 'my search name' search='error msg' | def create(name, profile="splunk", **kwargs):
'''
Create a splunk search
CLI Example:
splunk_search.create 'my search name' search='error msg'
'''
client = _get_splunk(profile)
search = client.saved_searches.create(name, **kwargs)
# use the REST API to set owner and permissions
... |
Sets DNS host records settings for the requested domain.
returns True if the host records were set successfully
sld
SLD of the domain name
tld
TLD of the domain name
hosts
Must be passed as a list of Python dictionaries, with each dictionary
containing the following k... | def set_hosts(sld, tld, hosts):
'''
Sets DNS host records settings for the requested domain.
returns True if the host records were set successfully
sld
SLD of the domain name
tld
TLD of the domain name
hosts
Must be passed as a list of Python dictionaries, with each d... |
Get a list of all the mirrored remote repositories.
:param str config_path: The path to the configuration file for the aptly instance.
:return: A list of the mirror names.
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' aptly.list_mirrors | def list_mirrors(config_path=_DEFAULT_CONFIG_PATH):
'''
Get a list of all the mirrored remote repositories.
:param str config_path: The path to the configuration file for the aptly instance.
:return: A list of the mirror names.
:rtype: list
CLI Example:
.. code-block:: bash
salt... |
Get detailed information about a local package repository.
:param str name: The name of the local repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing informatio... | def get_repo(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a local package repository.
:param str name: The name of the local repository.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: ... |
Process events and publish data | def process(self, salt_data, token, opts):
'''
Process events and publish data
'''
parts = salt_data['tag'].split('/')
if len(parts) < 2:
return
# TBD: Simplify these conditional expressions
if parts[1] == 'job':
if parts[3] == 'new':
... |
Ensure GPG public key is absent in keychain
name
The unique name or keyid for the GPG public key.
keys
The keyId or keyIds to add to the GPG keychain.
user
Remove GPG keys from the specified user's keychain
gnupghome
Override GNUPG Home directory | def absent(name,
keys=None,
user=None,
gnupghome=None,
**kwargs):
'''
Ensure GPG public key is absent in keychain
name
The unique name or keyid for the GPG public key.
keys
The keyId or keyIds to add to the GPG keychain.
user
Rem... |
Ensure we are using the latest revision in the hg repository | def update(self, branch='default'):
'''
Ensure we are using the latest revision in the hg repository
'''
log.debug('Updating hg repo from hg_pillar module (pull)')
self.repo.pull()
log.debug('Updating hg repo from hg_pillar module (update)')
self.repo.update(branc... |
Find and return any CloudFront distributions which happen to have a Comment sub-field
either exactly matching the given Comment, or beginning with it AND with the remainder
separated by a colon.
Comment
The string to be matched when searching for the given Distribution. Note that this
will... | def get_distributions_by_comment(Comment, region=None, key=None, keyid=None, profile=None):
'''
Find and return any CloudFront distributions which happen to have a Comment sub-field
either exactly matching the given Comment, or beginning with it AND with the remainder
separated by a colon.
Comment
... |
Publishes minions as a list of dicts. | def publish_minions(self):
'''
Publishes minions as a list of dicts.
'''
minions = []
for minion, minion_info in six.iteritems(self.minions):
curr_minion = {}
curr_minion.update(minion_info)
curr_minion.update({'id': minion})
minio... |
Query the vistara API and get an access_token | def _get_oath2_access_token(client_key, client_secret):
'''
Query the vistara API and get an access_token
'''
if not client_key and not client_secret:
log.error(
"client_key and client_secret have not been specified "
"and are required parameters."
)
retu... |
Calls an arbitrary netmiko method. | def call(method, *args, **kwargs):
'''
Calls an arbitrary netmiko method.
'''
kwargs = clean_kwargs(**kwargs)
if not netmiko_device['always_alive']:
connection = ConnectHandler(**netmiko_device['args'])
ret = getattr(connection, method)(*args, **kwargs)
connection.disconnect(... |
Format the common arguments for creating or editing a repository.
:param str comment: The description of the repository.
:param str component: The default component to use when publishing.
:param str distribution: The default distribution to use when publishing.
:param str uploaders_file: The repositor... | def _format_repo_args(comment=None, component=None, distribution=None,
uploaders_file=None, saltenv='base'):
'''
Format the common arguments for creating or editing a repository.
:param str comment: The description of the repository.
:param str component: The default component to ... |
Ensure that a property in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
name
Irrelevant, not used (recommended: pcs_properties__prop_has_value_{{prop}})
prop
name of the property
value
value of the property
extra_args
... | def prop_has_value(name, prop, value, extra_args=None, cibname=None):
'''
Ensure that a property in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
name
Irrelevant, not used (recommended: pcs_properties__prop_has_value_{{prop}})
prop
... |
Ensure a resource default in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant, not used (recommended: pcs_properties__resource_defaults_to_{{default}})
default
... | def resource_defaults_to(name, default, value, extra_args=None, cibname=None):
'''
Ensure a resource default in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant... |
Display specified jail's configuration
CLI Example:
.. code-block:: bash
salt '*' jail.show_config <jail name> | def show_config(jail):
'''
Display specified jail's configuration
CLI Example:
.. code-block:: bash
salt '*' jail.show_config <jail name>
'''
ret = {}
if subprocess.call(["jls", "-nq", "-j", jail]) == 0:
jls = subprocess.check_output(["jls", "-nq", "-j", jail]) # pylint: ... |
Return list of static and shared modules (``apachectl -M``)
CLI Example:
.. code-block:: bash
salt '*' apache.modules | def modules():
'''
Return list of static and shared modules (``apachectl -M``)
CLI Example:
.. code-block:: bash
salt '*' apache.modules
'''
cmd = '{0} -M'.format(_detect_os())
ret = {}
ret['static'] = []
ret['shared'] = []
out = __salt__['cmd.run'](cmd).splitlines()
... |
Get splunk search properties from an object | def _get_splunk_search_props(search):
'''
Get splunk search properties from an object
'''
props = search.content
props["app"] = search.access.app
props["sharing"] = search.access.sharing
return props |
Add tags to a CloudFront resource.
Resource
The ARN of the affected CloudFront resource.
Tags
Dict of {'Tag': 'Value', ...} providing the tags to be set.
region
Region to connect to.
key
Secret key to use.
keyid
Access key to use.
profile
Dic... | def tag_resource(region=None, key=None, keyid=None, profile=None, **kwargs):
'''
Add tags to a CloudFront resource.
Resource
The ARN of the affected CloudFront resource.
Tags
Dict of {'Tag': 'Value', ...} providing the tags to be set.
region
Region to connect to.
key
... |
Return which jails are set to be run
CLI Example:
.. code-block:: bash
salt '*' jail.get_enabled | def get_enabled():
'''
Return which jails are set to be run
CLI Example:
.. code-block:: bash
salt '*' jail.get_enabled
'''
ret = []
for rconf in ('/etc/rc.conf', '/etc/rc.conf.local'):
if os.access(rconf, os.R_OK):
with salt.utils.files.fopen(rconf, 'r') as _f... |
Update a splunk search
CLI Example:
splunk_search.update 'my search name' sharing=app | def update(name, profile="splunk", **kwargs):
'''
Update a splunk search
CLI Example:
splunk_search.update 'my search name' sharing=app
'''
client = _get_splunk(profile)
search = client.saved_searches[name]
props = _get_splunk_search_props(search)
updates = kwargs
update_ne... |
Retrieve a set of public keys from GitHub for the specified list of users.
Expects input in list format. Optionally, a value in the list may be a dict
whose value is a list of key IDs to be returned. If this is not done, then
all keys will be returned.
Some example data structures that coupld be passed... | def get_user_pubkeys(users):
'''
Retrieve a set of public keys from GitHub for the specified list of users.
Expects input in list format. Optionally, a value in the list may be a dict
whose value is a list of key IDs to be returned. If this is not done, then
all keys will be returned.
Some exam... |
Get module optional environment.
To setup an environment option for a particular module,
add either pillar or config at the minion as follows:
system-environment:
modules:
pkg:
_:
LC_ALL: en_GB.UTF-8
FOO: bar
install:
HELLO: world
... | def get_module_environment(env=None, function=None):
'''
Get module optional environment.
To setup an environment option for a particular module,
add either pillar or config at the minion as follows:
system-environment:
modules:
pkg:
_:
LC_ALL: en_GB.UTF-8
... |
Convert matching string values to lists/dictionaries.
:param dict parsed_data: The text of the command output that needs to be parsed.
:return: A dictionary containing the modified configuration data.
:rtype: dict | def _convert_parsed_show_output(parsed_data):
'''
Convert matching string values to lists/dictionaries.
:param dict parsed_data: The text of the command output that needs to be parsed.
:return: A dictionary containing the modified configuration data.
:rtype: dict
'''
# Match lines like "ma... |
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing ... | def get_mirror(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool wit... |
Get detailed information about a snapshot.
:param str name: The name of the snapshot given during snapshot creation.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the snapshot.
:return: A dictionary containing... | def get_snapshot(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a snapshot.
:param str name: The name of the snapshot given during snapshot creation.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with... |
Open the connection to the network device
managed through netmiko. | def init(opts):
'''
Open the connection to the network device
managed through netmiko.
'''
proxy_dict = opts.get('proxy', {})
opts['multiprocessing'] = proxy_dict.get('multiprocessing', False)
netmiko_connection_args = proxy_dict.copy()
netmiko_connection_args.pop('proxytype', None)
... |
Given a trail name, check to see if the given trail exists.
Returns True if the given trail exists and returns False if the given
trail does not exist.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.exists mytrail | def exists(Name,
region=None, key=None, keyid=None, profile=None):
'''
Given a trail name, check to see if the given trail exists.
Returns True if the given trail exists and returns False if the given
trail does not exist.
CLI Example:
.. code-block:: bash
salt myminion bo... |
Return True if a CloudFront origin access identity exists with the given Resource ID or False
otherwise.
Id
Resource ID of the CloudFront origin access identity.
region
Region to connect to.
key
Secret key to use.
keyid
Access key to use.
profile
Dict... | def cloud_front_origin_access_identity_exists(Id, region=None, key=None, keyid=None, profile=None):
'''
Return True if a CloudFront origin access identity exists with the given Resource ID or False
otherwise.
Id
Resource ID of the CloudFront origin access identity.
region
Region to... |
Delete an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_delete name=image1
salt '*' glanceng.image_delete name=0e4febc2a5ab4f2c8f374b054162506d | def image_delete(auth=None, **kwargs):
'''
Delete an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_delete name=image1
salt '*' glanceng.image_delete name=0e4febc2a5ab4f2c8f374b054162506d
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwargs... |
Get a single image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_get name=image1
salt '*' glanceng.image_get name=0e4febc2a5ab4f2c8f374b054162506d | def image_get(auth=None, **kwargs):
'''
Get a single image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_get name=image1
salt '*' glanceng.image_get name=0e4febc2a5ab4f2c8f374b054162506d
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwargs)
... |
Run the aptly command.
:return: The string output of the command.
:rtype: str | def _cmd_run(cmd):
'''
Run the aptly command.
:return: The string output of the command.
:rtype: str
'''
cmd.insert(0, 'aptly')
cmd_ret = __salt__['cmd.run_all'](cmd, ignore_retcode=True)
if cmd_ret['retcode'] != 0:
log.debug('Unable to execute command: %s\nError: %s', cmd,
... |
Ensure a resource operation default in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
Irrelevant, not used (recommended: pcs_properties__resource_op_defaults_to_{{op_default}})
... | def resource_op_defaults_to(name, op_default, value, extra_args=None, cibname=None):
'''
Ensure a resource operation default in the cluster is set to a given value
Should be run on one cluster node only
(there may be races)
Can only be run on a node with a functional pacemaker/corosync
name
... |
See if jail service is actually enabled on boot
CLI Example:
.. code-block:: bash
salt '*' jail.is_enabled <jail name> | def is_enabled():
'''
See if jail service is actually enabled on boot
CLI Example:
.. code-block:: bash
salt '*' jail.is_enabled <jail name>
'''
cmd = 'service -e'
services = __salt__['cmd.run'](cmd, python_shell=False)
for service in services.split('\\n'):
if re.searc... |
Execute a single action on the given map/provider/instance
CLI Example:
.. code-block:: bash
salt-run cloud.action start my-salt-vm | def action(func=None,
cloudmap=None,
instances=None,
provider=None,
instance=None,
opts=None,
**kwargs):
'''
Execute a single action on the given map/provider/instance
CLI Example:
.. code-block:: bash
salt-run cloud.action sta... |
Create an instance using Salt Cloud
CLI Example:
.. code-block:: bash
salt-run cloud.create my-ec2-config myinstance \
image=ami-1624987f size='t1.micro' ssh_username=ec2-user \
securitygroup=default delvol_on_destroy=True | def create(provider, instances, opts=None, **kwargs):
'''
Create an instance using Salt Cloud
CLI Example:
.. code-block:: bash
salt-run cloud.create my-ec2-config myinstance \
image=ami-1624987f size='t1.micro' ssh_username=ec2-user \
securitygroup=default delvol_on_d... |
Remove information about a snapshot. If a snapshot is published, it can not be
dropped without first removing publishing for that snapshot. If a snapshot is
used as the source for other snapshots, Aptly will refuse to remove it unless
forced.
:param str name: The name of the snapshot given ... | def delete_snapshot(name, config_path=_DEFAULT_CONFIG_PATH, force=False):
'''
Remove information about a snapshot. If a snapshot is published, it can not be
dropped without first removing publishing for that snapshot. If a snapshot is
used as the source for other snapshots, Aptly will refuse to ... |
Given a trail name describe its properties.
Returns a dictionary of interesting properties.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.describe mytrail | def describe(Name,
region=None, key=None, keyid=None, profile=None):
'''
Given a trail name describe its properties.
Returns a dictionary of interesting properties.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.describe mytrail
'''
try:
co... |
Dump all jail related kernel states (sysctl)
CLI Example:
.. code-block:: bash
salt '*' jail.sysctl | def sysctl():
'''
Dump all jail related kernel states (sysctl)
CLI Example:
.. code-block:: bash
salt '*' jail.sysctl
'''
ret = {}
sysctl_jail = __salt__['cmd.run']('sysctl security.jail')
for line in sysctl_jail.splitlines():
key, value = line.split(':', 1)
re... |
Make sure that a gem is not installed.
name
The name of the gem to uninstall
gem_bin : None
Full path to ``gem`` binary to use.
ruby : None
If RVM or rbenv are installed, the ruby version and gemset to use.
Ignored if ``gem_bin`` is specified.
user: None
The u... | def removed(name, ruby=None, user=None, gem_bin=None):
'''
Make sure that a gem is not installed.
name
The name of the gem to uninstall
gem_bin : None
Full path to ``gem`` binary to use.
ruby : None
If RVM or rbenv are installed, the ruby version and gemset to use.
... |
Publishes the data to the event stream. | def publish(self, key, data):
'''
Publishes the data to the event stream.
'''
publish_data = {key: data}
self.handler.send(salt.utils.json.dumps(publish_data), False) |
Given a trail name describe its properties.
Returns a dictionary of interesting properties.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.describe mytrail | def status(Name,
region=None, key=None, keyid=None, profile=None):
'''
Given a trail name describe its properties.
Returns a dictionary of interesting properties.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.describe mytrail
'''
try:
conn... |
Ensure the Route53 record is present.
name
The name of the state definition. This will be used for Name if the latter is
not provided.
HostedZoneId
The ID of a zone to create the record in. Exclusive with DomainName.
DomainName
The domain name of a zone to create the rec... | def rr_present(name, HostedZoneId=None, DomainName=None, PrivateZone=False, Name=None, Type=None,
SetIdentifier=None, Weight=None, Region=None, GeoLocation=None, Failover=None,
TTL=None, ResourceRecords=None, AliasTarget=None, HealthCheckId=None,
TrafficPolicyInstanceId=None... |
Create an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw
salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw hw_scsi_model=virtio-scsi hw_disk_bus=scsi | def image_create(auth=None, **kwargs):
'''
Create an image
CLI Example:
.. code-block:: bash
salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw
salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw hw_scsi_model=virtio-scsi hw_disk_bus=scsi... |
Return server version (``apachectl -V``)
CLI Example:
.. code-block:: bash
salt '*' apache.fullversion | def fullversion():
'''
Return server version (``apachectl -V``)
CLI Example:
.. code-block:: bash
salt '*' apache.fullversion
'''
cmd = '{0} -V'.format(_detect_os())
ret = {}
ret['compiled_with'] = []
out = __salt__['cmd.run'](cmd).splitlines()
# Example
# -D APR_... |
Setup Pacemaker cluster on nodes.
Should be run on one cluster node only
(there may be races)
name
Irrelevant, not used (recommended: pcs_setup__setup)
nodes
a list of nodes which should be set up
pcsclustername
Name of the Pacemaker cluster
extra_args
list of ex... | def cluster_setup(name, nodes, pcsclustername='pcscluster', extra_args=None):
'''
Setup Pacemaker cluster on nodes.
Should be run on one cluster node only
(there may be races)
name
Irrelevant, not used (recommended: pcs_setup__setup)
nodes
a list of nodes which should be set up
... |
See if specified jail is currently running
CLI Example:
.. code-block:: bash
salt '*' jail.status <jail name> | def status(jail):
'''
See if specified jail is currently running
CLI Example:
.. code-block:: bash
salt '*' jail.status <jail name>
'''
cmd = 'jls'
found_jails = __salt__['cmd.run'](cmd, python_shell=False)
for found_jail in found_jails.split('\\n'):
if re.search(jail,... |
Execute a salt cloud map file | def map_run(path=None, opts=None, **kwargs):
'''
Execute a salt cloud map file
'''
client = _get_client()
if isinstance(opts, dict):
client.opts.update(opts)
info = client.map_run(path, **salt.utils.args.clean_kwargs(**kwargs))
return info |
Make sure that a gem source is removed.
name
The URL of the gem source to be removed
ruby: None
For RVM or rbenv installations: the ruby version and gemset to target.
user: None
The user under which to run the ``gem`` command
.. versionadded:: 0.17.0 | def sources_remove(name, ruby=None, user=None):
'''
Make sure that a gem source is removed.
name
The URL of the gem source to be removed
ruby: None
For RVM or rbenv installations: the ruby version and gemset to target.
user: None
The user under which to run the ``gem`` com... |
Get alarm details. Also can be used to check to see if an alarm exists.
CLI example::
salt myminion boto_cloudwatch.get_alarm myalarm region=us-east-1 | def get_alarm(name, region=None, key=None, keyid=None, profile=None):
'''
Get alarm details. Also can be used to check to see if an alarm exists.
CLI example::
salt myminion boto_cloudwatch.get_alarm myalarm region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile... |
Extract pillar from an hg repository | def ext_pillar(minion_id, pillar, repo, branch='default', root=None):
'''
Extract pillar from an hg repository
'''
with Repo(repo) as repo:
repo.update(branch)
envname = 'base' if branch == 'default' else branch
if root:
path = os.path.normpath(os.path.join(repo.working_dir, root... |
Destroy the named vm(s) | def destroy(instances, opts=None):
'''
Destroy the named vm(s)
'''
client = _get_client()
if isinstance(opts, dict):
client.opts.update(opts)
info = client.destroy(instances)
return info |
Ensure the Route53 Hostes Zone described is absent
name
The name of the state definition.
Name
The name of the domain. This should be a fully-specified domain, and should terminate with a
period. If not provided, the value of name will be used.
PrivateZone
Set True if del... | def hosted_zone_absent(name, Name=None, PrivateZone=False,
region=None, key=None, keyid=None, profile=None):
'''
Ensure the Route53 Hostes Zone described is absent
name
The name of the state definition.
Name
The name of the domain. This should be a fully-specifie... |
.. versionadded:: 2014.7.0
Flush current ipset set
family
Networking family, either ipv4 or ipv6 | def flush(name, family='ipv4', **kwargs):
'''
.. versionadded:: 2014.7.0
Flush current ipset set
family
Networking family, either ipv4 or ipv6
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
set_check = __salt__['ipset.check... |
Retrieves DNS host record settings for the requested domain.
returns a dictionary of information about the requested domain
sld
SLD of the domain name
tld
TLD of the domain name
CLI Example:
.. code-block:: bash
salt 'my-minion' namecheap_domains_dns.get_hosts sld tld | def get_hosts(sld, tld):
'''
Retrieves DNS host record settings for the requested domain.
returns a dictionary of information about the requested domain
sld
SLD of the domain name
tld
TLD of the domain name
CLI Example:
.. code-block:: bash
salt 'my-minion' name... |
Get information about a CloudFront distribution (configuration, tags) with a given name.
name
Name of the CloudFront distribution
region
Region to connect to
key
Secret key to use
keyid
Access key to use
profile
A dict with region, key, and keyid,
... | def get_distribution(name, region=None, key=None, keyid=None, profile=None):
'''
Get information about a CloudFront distribution (configuration, tags) with a given name.
name
Name of the CloudFront distribution
region
Region to connect to
key
Secret key to use
keyid
... |
Ensure the current node joined to a cluster with node user@host
name
Irrelevant, not used (recommended: user@host)
user
The user of node to join to (default: rabbit)
host
The host of node to join to
ram_node
Join node as a RAM node
runas
The user to run the r... | def joined(name, host, user='rabbit', ram_node=None, runas='root'):
'''
Ensure the current node joined to a cluster with node user@host
name
Irrelevant, not used (recommended: user@host)
user
The user of node to join to (default: rabbit)
host
The host of node to join to
... |
Allow top_cfg to be YAML | def _parse_top_cfg(content, filename):
'''
Allow top_cfg to be YAML
'''
try:
obj = salt.utils.yaml.safe_load(content)
if isinstance(obj, list):
log.debug('MakoStack cfg `%s` parsed as YAML', filename)
return obj
except Exception as err:
pass
log.de... |
Display contents of a fstab(5) file defined in specified
jail's configuration. If no file is defined, return False.
CLI Example:
.. code-block:: bash
salt '*' jail.fstab <jail name> | def fstab(jail):
'''
Display contents of a fstab(5) file defined in specified
jail's configuration. If no file is defined, return False.
CLI Example:
.. code-block:: bash
salt '*' jail.fstab <jail name>
'''
ret = []
config = show_config(jail)
if 'fstab' in config:
... |
List splunk searches (names only)
CLI Example:
splunk_search.list | def list_(profile="splunk"):
'''
List splunk searches (names only)
CLI Example:
splunk_search.list
'''
client = _get_splunk(profile)
searches = [x['name'] for x in client.saved_searches]
return searches |
Remove data regarding unreferenced packages and delete files in the package pool that
are no longer being used by packages.
:param bool dry_run: Report potential changes without making any changes.
:return: A dictionary of the package keys and files that were removed.
:rtype: dict
CLI Example... | def cleanup_db(config_path=_DEFAULT_CONFIG_PATH, dry_run=False):
'''
Remove data regarding unreferenced packages and delete files in the package pool that
are no longer being used by packages.
:param bool dry_run: Report potential changes without making any changes.
:return: A dictionary of th... |
Add tags to a trail
Returns {tagged: true} if the trail was tagged and returns
{tagged: False} if the trail was not tagged.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.add_tags my_trail tag_a=tag_value tag_b=tag_value | def add_tags(Name,
region=None, key=None, keyid=None, profile=None, **kwargs):
'''
Add tags to a trail
Returns {tagged: true} if the trail was tagged and returns
{tagged: False} if the trail was not tagged.
CLI Example:
.. code-block:: bash
salt myminion boto_cloudtrail.ad... |
Find and return any CloudFront Origin Access Identities which happen to have a Comment
sub-field either exactly matching the given Comment, or beginning with it AND with the
remainder separate by a colon.
Comment
The string to be matched when searching for the given Origin Access Identity. Note
... | def get_cloud_front_origin_access_identities_by_comment(Comment, region=None, key=None, keyid=None,
profile=None):
'''
Find and return any CloudFront Origin Access Identities which happen to have a Comment
sub-field either exactly matching the given Co... |
.. versionadded:: 2014.7.0
Verify the set is absent.
family
Networking family, either ipv4 or ipv6 | def set_absent(name, family='ipv4', **kwargs):
'''
.. versionadded:: 2014.7.0
Verify the set is absent.
family
Networking family, either ipv4 or ipv6
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
set_check = __salt__['ipse... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.