### Configure MSI Installation with msiexec Path Source: https://docs.saltproject.io/en/latest/topics/windows/windows-package-manager.html Example demonstrating how to configure an MSI installation by explicitly providing the path to `msiexec.exe`. This ensures Salt uses the correct executable for installation and uninstallation. ```yaml 7zip: '9.20.00.0': full_name: 7-Zip 9.20 (x64 edition) installer: salt://win/repo/7zip/7z920-x64.msi install_flags: '/qn /norestart' uninstaller: salt://win/repo/7zip/7z920-x64.msi uninstall_flags: '/qn /norestart' msiexec: 'C:\\Windows\\System32\\msiexec.exe' ``` -------------------------------- ### Install Single or Multiple Packages Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_pkg.html Provides examples for installing a single package, multiple packages using a comma-separated list, and multiple packages using a list in the `pkgs` argument. ```bash salt '*' pkg.install 7zip ``` ```bash salt '*' pkg.install 7zip,filezilla ``` ```bash salt '*' pkg.install pkgs='["7zip","filezilla"]' ``` -------------------------------- ### Install Package Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.zypperpkg.html Installs a specified package. This example demonstrates installing a package by name. The `pkgs` parameter can be used to install multiple packages from a list. ```yaml salt '*' pkg.install name= ``` -------------------------------- ### Package Installation with List Context (2019.2.0+) Source: https://docs.saltproject.io/en/latest/topics/releases/2019.2.0.html This example shows how to correctly install packages when the package names are provided as a list or dictionary in the Salt state, using the `tojson` Jinja filter. ```yaml grafana_packages: pkg.installed: - names: {{ server.pkgs|tojson }} ``` -------------------------------- ### Get Help for Tools Test Suite Setup Source: https://docs.saltproject.io/en/latest/topics/packaging/testing.html Displays help information for the `tools ts setup` command, showing available options and arguments for setting up package test artifacts. ```bash tools ts setup -h ``` -------------------------------- ### Manage custom repositories and install packages Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html This example demonstrates how to manage a custom APT repository using `pkgrepo.managed` and then install a package from that specific repository using `pkg.installed` with the `fromrepo` option. ```yaml base: pkgrepo.managed: - name: ppa:wolfnet/logstash - dist: precise - file: /etc/apt/sources.list.d/logstash.list - keyid: 28B04E4A - keyserver: keyserver.ubuntu.com logstash: pkg.installed: - fromrepo: ppa:wolfnet/logstash ``` -------------------------------- ### Install Cowsay with Default Splaytime Source: https://docs.saltproject.io/en/latest/ref/executors/all/salt.executors.splay.html This example demonstrates installing a package using the splay executor with its default splaytime. The `--async` flag is recommended for non-blocking execution, allowing you to check job results later. ```bash salt --async --module-executors='[splay, direct_call]' '*' pkg.install cowsay version=3.03-8.el6 ``` -------------------------------- ### Example GET Request for Login Source: https://docs.saltproject.io/en/latest/ref/netapi/all/salt.netapi.rest_tornado.html Demonstrates how to make a GET request to the /login endpoint. This endpoint is parked and not intended for actual logins. ```bash curl -i localhost:8000/login ``` ```http GET /login HTTP/1.1 Host: localhost:8000 Accept: application/json ``` -------------------------------- ### CLI Example: Get Package Version Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_pkg.html Command-line interface examples for retrieving package versions using the salt command. ```bash salt '*' pkg.version salt '*' pkg.version ``` -------------------------------- ### Install Single Package with Refresh Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_pkg.html This example refreshes the winrepo cache and then installs the '7zip' package. The `refresh=True` argument ensures that the package metadata is up-to-date before installation. ```bash salt '*' pkg.install 7zip refresh=True ``` -------------------------------- ### Example Return Data for list_pkgs Source: https://docs.saltproject.io/en/latest/topics/development/package_providers.html Illustrates the expected dictionary format for the `list_pkgs` function, where keys are package names and values are their installed versions. ```json {"foo": "1.2.3-4", "bar": "5.6.7-8"} ``` -------------------------------- ### Install Salt with Easy Install and SetupTools Source: https://docs.saltproject.io/en/latest/topics/development/hacking.html Installs Salt using `easy_install`, ensuring dependencies are installed by defining the USE_SETUPTOOLS environment variable. ```bash USE_SETUPTOOLS=1 easy_install salt ``` -------------------------------- ### Install update using full Title Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_wua.html This example illustrates installing an update by providing its full title string to the `name` parameter in the `wua.installed` state. Note that using partial titles or KB numbers can lead to unintended installations. ```yaml install_update: wua.installed: - name: Security Update for Adobe Flash Player for Windows 10 Version 1607 (for x64-based Systems) (KB3194343) ``` -------------------------------- ### Saltcheck Test File Example Source: https://docs.saltproject.io/en/latest/topics/releases/3000.html An example of a Saltcheck test file written in YAML, demonstrating setup, conditional testing with Jinja, assertions, and skipping tests. The `saltcheck.state_apply` module is used for test setup. ```yaml {# will run the common salt state before further testing #} setup_test_environment: module_and_function: saltcheck.state_apply args: - common pillar-data: data: value {% for package in ["apache2", "openssh"] %} {# or another example #} {# for package in salt['pillar.get']("packages") #} jinja_test_{{ package }}_latest: module_and_function: pkg.upgrade_available args: - {{ package }} assertion: assertFalse {% endfor %} validate_user_present_and_shell: module_and_function: user.info args: - root assertion: assertEqual expected-return: /bin/bash assertion_section: shell print_result: False skip_test: module_and_function: pkg.upgrade_available args: - apache2 assertion: assertFalse skip: True ``` -------------------------------- ### Install IIS with dsc_resource Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_dsc_resource.html Example of installing IIS using the `dsc_resource.managed` state. This ensures the 'Web-Server' Windows feature is present. ```yaml install_iis: dsc_resource.managed: - name: WindowsFeature - module_name: PSDesiredStateConfiguration - properties: Name: Web-Server Ensure: Present ``` -------------------------------- ### Update RHEL Installation Guide Source: https://docs.saltproject.io/en/latest/topics/releases/2015.8.8.html Updates the RHEL installation guide to reflect recent repository changes and provides systemctl examples for RHEL 7. ```yaml 6370ddda9f Update RHEL installation guide ``` ```yaml afdaefbf3d Add systemctl examples for RHEL 7 to the installation guide ``` ```yaml 069a661eb1 Correct ZeroMQ4 repo install guide for RHEL ``` ```yaml d2a9d67b5b Update installation instruction for community repos on RHEL ``` ```yaml bbdf2523c8 Add workaround for RHEL 7 systems mentioned in the issue #29094 ``` -------------------------------- ### Create a shortcut with parent directory creation Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_shortcut.html This example shows how to create a shortcut and ensure that any necessary parent directories are created if they do not already exist. This simplifies deployment to deep directory structures. ```salt salt '*' shortcut.create 'C:\path\to\shortcut.lnk' 'C:\Windows\notepad.exe' make_dirs=True ``` -------------------------------- ### Conditional Test Execution with setUp Source: https://docs.saltproject.io/en/latest/topics/development/tests/integration.html Use the `setUp` function to check test applicability and skip if requirements are not met. This example ensures the test only runs on macOS by checking the kernel grain. ```python def setUp(self): """ Sets up test requirements """ os_grain = self.run_function("grains.item", ["kernel"]) if os_grain["kernel"] not in "Darwin": self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain)) ``` -------------------------------- ### Uninstall Software Using MSI Installer Source: https://docs.saltproject.io/en/latest/topics/windows/windows-package-manager.html Example of uninstalling software by specifying the MSI installer path. This method is useful when the GUID is not readily available. ```yaml 7zip: '9.20.00.0': full_name: 7-Zip 9.20 (x64 edition) installer: salt://win/repo-ng/7zip/7z920-x64.msi install_flags: '/qn /norestart' uninstaller: salt://win/repo-ng/7zip/7z920-x64.msi uninstall_flags: '/qn /norestart' msiexec: True ``` -------------------------------- ### Install multiple updates using list Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_wua.html Demonstrates installing a collection of Windows updates by providing a list of their identifiers (KB numbers or GUIDs) to the `updates` parameter in the `wua.installed` state. ```yaml install_updates: wua.installed: - updates: - KB3194343 - 28cf1b09-2b1a-458c-9bd1-971d1b26b211 ``` -------------------------------- ### Get all disabled services Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.debian_service.html Returns a set of services that are installed but currently disabled from starting at boot. This helps identify services that are not set to start automatically. ```salt salt '*' service.get_disabled ``` -------------------------------- ### Initialize VM with QEMU Copy on Write Source: https://docs.saltproject.io/en/latest/topics/tutorials/cloud_controller.html Use this command to initialize a new virtual machine using the qcow disk image format for fast cloning. It's recommended to set `start=False` to avoid race conditions during image seeding. ```bash salt 'hypervisor*' virt.init centos1 2 512 image=/var/lib/libvirt/images/centos.qcow2 enable_qcow=True start=False ``` -------------------------------- ### Require Requisite Example Source: https://docs.saltproject.io/en/latest/ref/states/requisites.html Standard 'require' requisite ensuring the httpd package is installed before the service starts. ```yaml httpd: pkg.installed: [] service.running: - require: - pkg: httpd ``` -------------------------------- ### salt.proxy.dummy.service_start(_name_) Source: https://docs.saltproject.io/en/latest/ref/proxy/all/salt.proxy.dummy.html Start a "service" on the dummy server. ```APIDOC ## salt.proxy.dummy.service_start(_name_) ### Description Start a "service" on the dummy server. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ### Response Example APIDOC ``` -------------------------------- ### Get Specific Windows Update Details Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_wua.html Retrieves details for a specific Windows update by its name, GUID, or KB number. Can optionally download or install the update, and control whether to check online for updates. ```yaml salt '*' win_wua.get name='12345678-abcd-1234-abcd-1234567890ab' ``` -------------------------------- ### CLI Example: Initialize Git Repository Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html Example of how to initialize a Git repository using the Salt CLI. ```bash salt myminion git.init /path/to/repo ``` -------------------------------- ### Install a single update using the name parameter Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_wua.html This example demonstrates installing a single update by explicitly providing its identifier to the `name` parameter within the `wua.installed` state. ```yaml install_update: wua.installed: - name: KB3194343 ``` -------------------------------- ### CLI Example: Get Public Key Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.x509_v2.html Example of how to use the x509.get_public_key function from the Salt CLI to retrieve the public key from a private key file. ```bash salt '*' x509.get_public_key /etc/pki/my.key ``` -------------------------------- ### Get git config keys matching a key regex Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html Retrieves all values for git configuration keys that match a provided regular expression. This example specifically targets keys starting with 'user.' in the global configuration. ```bash salt myminion git.config_get_regexp '^user\.' global=True ``` -------------------------------- ### Install update using GUID Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_wua.html Demonstrates installing a specific Windows update using its GUID as the identifier with the `wua.installed` state. ```yaml install_update: wua.installed: - name: 28cf1b09-2b1a-458c-9bd1-971d1b26b211 ``` -------------------------------- ### syslog-ng Full Configuration Example Source: https://docs.saltproject.io/en/latest/topics/tutorials/syslog_ng-state-usage.html A comprehensive example demonstrating how to set up a complete syslog-ng configuration using various SaltStack modules and `syslog_ng.config`. ```yaml # Set the location of the configuration file set_location: module.run: - name: syslog_ng.set_config_file - m_name: "/home/tibi/install/syslog-ng/etc/syslog-ng.conf" # The syslog-ng and syslog-ng-ctl binaries are here. You needn't use # this method if these binaries can be found in a directory in your PATH. set_bin_path: module.run: - name: syslog_ng.set_binary_path - m_name: "/home/tibi/install/syslog-ng/sbin" # Writes the first lines into the config file, also erases its previous # content write_version: module.run: - name: syslog_ng.write_version - m_name: "3.6" # There is a shorter form to set the above variables set_variables: module.run: - name: syslog_ng.set_parameters - version: "3.6" - binary_path: "/home/tibi/install/syslog-ng/sbin" - config_file: "/home/tibi/install/syslog-ng/etc/syslog-ng.conf" # Some global options options.global_options: syslog_ng.config: - config: - time_reap: 30 - mark_freq: 10 - keep_hostname: "yes" source.s_localhost: syslog_ng.config: - config: - tcp: - ip: "127.0.0.1" - port: 1233 destination.d_log_server: syslog_ng.config: - config: - tcp: - "127.0.0.1" - port: 1234 log.l_log_to_central_server: syslog_ng.config: - config: - source: s_localhost - destination: d_log_server some_comment: module.run: - name: syslog_ng.write_config - config: | # Multi line # comment # Another mode to use comments or existing configuration snippets config.other_comment_form: syslog_ng.config: - config: | # Multi line # comment ``` -------------------------------- ### Example GET request for /events Source: https://docs.saltproject.io/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html This example shows how to make a basic GET request to the /events endpoint to stream Salt master events. ```bash curl -NsS localhost:8000/events ``` ```http GET /events HTTP/1.1 Host: localhost:8000 ``` -------------------------------- ### salt.modules.dummyproxy_service.start Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.dummyproxy_service.html Starts the specified service on the dummy proxy. ```APIDOC ## salt.modules.dummyproxy_service.start ### Description Start the specified service on the dummy. ### Parameters * **_name_** (string) - The name of the service to start. * **_sig_** (string, optional) - Signature for the service. ### CLI Example ``` salt '*' service.start ``` ### New in version 2016.11.3 ``` -------------------------------- ### CLI Example: Get Private Key Size Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.x509_v2.html Example of how to use the x509.get_private_key_size function from the Salt CLI to get the size of a private key. ```bash salt '*' x509.get_private_key_size /etc/pki/my.key ``` -------------------------------- ### Install Windows Updates Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_wua.html Installs specified Windows updates. Updates can be identified by GUIDs, KB numbers, or names. It is recommended to use GUIDs or KBs for precise identification. ```salt salt '*' win_wua.install KB12323211 ``` -------------------------------- ### Using Pillar Data for Git Package Installation Source: https://docs.saltproject.io/en/latest/topics/pillar/index.html This example demonstrates referencing the 'git' pillar key within a state definition to install the Git package, utilizing Jinja templating. ```yaml git: pkg.installed: - name: {{ pillar['git'] }} ``` -------------------------------- ### enable Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.debian_service.html Enable the named service to start at boot. ```APIDOC ## enable(_name_ , _** kwargs_) ### Description Enable the named service to start at boot. ### Parameters * **name** (_str_) -- The name of the service to enable. * **kwargs** -- Additional keyword arguments. ### CLI Example ``` salt '*' service.enable ``` ``` -------------------------------- ### Get all installed services Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.smf_service.html Returns a list or dictionary of all installed services on the system. ```APIDOC ## service.get_all ### Description Return all installed services. ### CLI Example ``` salt '*' service.get_all ``` ``` -------------------------------- ### Get Installed PostgreSQL Extension Info Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.postgres.html Retrieves information about an installed PostgreSQL extension. Use this to verify installation and configuration. ```salt salt '*' postgres.get_installed_extension plpgsql ``` -------------------------------- ### Uninstall Software Using GUID Source: https://docs.saltproject.io/en/latest/topics/windows/windows-package-manager.html Example of uninstalling software using its unique GUID. Ensure the GUID is correct for the target software. ```yaml 7zip: '9.20.00.0': full_name: 7-Zip 9.20 (x64 edition) installer: salt://win/repo-ng/7zip/7z920-x64.msi install_flags: '/qn /norestart' uninstaller: '{23170F69-40C1-2702-0920-000001000000}' uninstall_flags: '/qn /norestart' msiexec: True ``` -------------------------------- ### HTTP GET Request for Events Source: https://docs.saltproject.io/en/latest/ref/netapi/all/salt.netapi.rest_tornado.html An example of the HTTP GET request sent to the events endpoint. ```http GET /events HTTP/1.1 Host: localhost:8000 ``` -------------------------------- ### CLI Example for Creating a Certificate Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.x509.html This command-line example shows how to create a certificate using the x509.create_certificate function, specifying paths for the certificate, private key, and CSR. ```bash salt '*' x509.create_certificate path=/etc/pki/myca.crt signing_private_key='/etc/pki/myca.key' csr='/etc/pki/myca.csr'} ``` -------------------------------- ### Configure Package Installation with Advanced Options Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html This example demonstrates installing a specific package version from a custom repository, skipping verification, and setting cache validity time. The `refresh` parameter controls repository database updates. ```yaml httpd: pkg.installed: - fromrepo: mycustomrepo - skip_verify: True - skip_suggestions: True - version: 2.0.6~ubuntu3 - refresh: True - cache_valid_time: 300 - allow_updates: True - hold: False ``` -------------------------------- ### Get Information on Installed Packages Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.yumpkg.html Retrieves detailed information about installed packages. Can fetch information for multiple packages and optionally include all installed versions. ```bash salt '*' pkg.info_installed salt '*' pkg.info_installed ... salt '*' pkg.info_installed all_versions=True ``` -------------------------------- ### salt.resources.dummy.service_start Source: https://docs.saltproject.io/en/latest/ref/resources/all/salt.resources.dummy.html Starts a "service" on the current dummy resource. ```APIDOC ## salt.resources.dummy.service_start ### Description Start a "service" on the current dummy resource. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (str) - Required - The name of the service to start. ### Response #### Success Response (200) - **return_value** (None) - Indicates successful start. ### Request Example ```json { "name": "example-service" } ``` ### Response Example ```json null ``` ``` -------------------------------- ### Get Package Version Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.pkgutil.html Returns the installed version of a package. Returns an empty string if the package is not installed. ```salt salt '*' pkgutil.version CSWpython ``` -------------------------------- ### salt.proxy.dummy.package_install(_name_, _**kwargs_) Source: https://docs.saltproject.io/en/latest/ref/proxy/all/salt.proxy.dummy.html Install a "package" on the REST server. ```APIDOC ## salt.proxy.dummy.package_install(_name_, _**kwargs_) ### Description Install a "package" on the REST server. ### Method APIDOC ### Endpoint APIDOC ### Parameters APIDOC ### Request Example APIDOC ### Response APIDOC ### Response Example APIDOC ``` -------------------------------- ### Basic Python Renderer for Package Installation Source: https://docs.saltproject.io/en/latest/topics/tutorials/starting_states.html This example demonstrates a minimal Python SLS file using the 'py' renderer. The `run` function returns a Salt HighState data structure to install the 'django' package. ```python #!py def run(): """ Install the django package """ return {"include": ["python"], "django": {"pkg": ["installed"]}} ``` -------------------------------- ### Build and Preview Salt Documentation Locally Source: https://docs.saltproject.io/en/latest/topics/development/contributing.html Builds the Salt documentation using nox, opens it in a web browser, and starts a local HTTP server. This command is used for the initial build. ```bash python -m nox -e 'docs-html(compress=False, clean=False)'; cd doc/_build/html; python -m webbrowser http://localhost:8000/contents.html; python -m http.server ``` -------------------------------- ### Salt State Execution: Nginx Installed (No Unless) Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html Example output of a Salt state run for nginx installation when no 'unless' requisite is used and the package is already installed. ```text salt 'saltdev' state.apply nginx saltdev: ---------- ID: install_nginx Function: pkg.installed Name: nginx Result: True Comment: All specified packages are already installed Started: 20:11:56.388331 Duration: 4290.0 ms Changes: ``` -------------------------------- ### CLI Example for locate.version Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.locate.html Example of how to use the locate.version function from the Salt command line. ```bash salt '*' locate.version ``` -------------------------------- ### Start release notes file for 2015.8.12 Source: https://docs.saltproject.io/en/latest/topics/releases/2015.8.12.html Initializes the release notes file for the 2015.8.12 version. ```yaml PR #35043: (rallytime) Start release notes file for 2015.8.12 @ _2016-08-01 17:22:04 UTC_ ``` ```yaml 343576408f Merge pull request #35043 from rallytime/new-release-notes ``` ```yaml bdcc81a384 Start release notes file for 2015.8.12 ``` -------------------------------- ### Install Multiple Python Packages Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pip_state.html Installs multiple Python packages simultaneously, specifying version constraints for each. This example installs Django and psycopg2 with their respective version requirements. ```yaml django-and-psycopg2: pip.installed: - pkgs: - django >= 1.6, <= 1.7 - psycopg2 >= 2.8.4 - require: - pkg: python-pip ``` -------------------------------- ### Cache Entire Directory for Installer Source: https://docs.saltproject.io/en/latest/topics/windows/windows-package-manager.html Example of using `cache_dir: True` to cache the entire directory containing the installer. This is beneficial for installers that rely on other files within the same directory. ```yaml sqlexpress: '12.0.2000.8': full_name: Microsoft SQL Server 2014 Setup (English) installer: 'salt://win/repo/sqlexpress/setup.exe' install_flags: '/ACTION=install /IACCEPTSQLSERVERLICENSETERMS /Q' cache_dir: True ``` -------------------------------- ### salt.modules.win_license.install Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_license.html Installs the given product key using the slmgr.vbs script. ```APIDOC ## install(_product_key_) ### Description Installs the given product key. ### Method `salt '*' ### Endpoint `license.install` ### Parameters #### Path Parameters - **product_key** (str) - Required - The product key to install. ### CLI Example ``` salt '*' license.install XXXXX-XXXXX-XXXXX-XXXXX-XXXXX ``` ### Returns The output of the `slmgr.vbs` script. ### Return type str ``` -------------------------------- ### up Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.rh_ip.html Start up a network interface. ```APIDOC ## up ### Description Start up a network interface. ### Method `salt` ### Endpoint `ip.up` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **iface** (string) - Required - The name of the network interface. * **iface_type** (string) - Required - The type of the interface. ### Request Example ``` salt '*' ip.up eth0 ``` ### Response #### Success Response (200) Details about the success response are not provided in the source. ``` -------------------------------- ### Get Git Version Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html Retrieves the version of Git installed on the minion. Set `_versioninfo` to `True` to get the version as a list. ```salt salt myminion git.version ``` -------------------------------- ### Get Installed Applications with OSQuery Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.osquery.html Retrieves a list of installed applications from OSQuery. This is useful for software inventory and compliance checks. ```salt salt '*' osquery.apps ``` -------------------------------- ### Complete Example in etc/salt/master Source: https://docs.saltproject.io/en/latest/ref/pillar/all/salt.pillar.extra_minion_data_in_pillar.html This example shows how to configure the `extra_minion_data_in_pillar` in `/etc/salt/master` to include all keys in the pillar. ```yaml ext_pillar: - extra_minion_data_in_pillar: include: * ``` -------------------------------- ### bootstrap Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_psget.html Ensure that nuget-anycpu.exe is installed by downloading it from the internet. ```APIDOC ## bootstrap ### Description Make sure that nuget-anycpu.exe is installed. This will download the official nuget-anycpu.exe from the internet. ### CLI Example ``` salt 'win01' psget.bootstrap ``` ``` -------------------------------- ### Add CLI examples for ldap3 module Source: https://docs.saltproject.io/en/latest/topics/releases/2016.3.2.html Provides command-line interface examples for the 'ldap3' module. These examples illustrate common operations and usage patterns for managing LDAP data via the Salt CLI. ```python 6fa40a0d46 Add cli examples for ldap3 module ``` -------------------------------- ### Generate and Accept New Minion Key Source: https://docs.saltproject.io/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html This example demonstrates bootstrapping a new minion by generating its keys and automatically accepting them on the master. It's crucial to avoid the `-i` flag with `curl` to prevent writing HTTP headers to the output tarball, which would corrupt it. The script sets up the minion's PKI directory, downloads the keys, and configures the master address. ```shell %post mkdir -p /etc/salt/pki/minion curl -sSk https://localhost:8000/keys \ -d mid=jerry \ -d username=kickstart \ -d password=kickstart \ -d eauth=pam \ | tar -C /etc/salt/pki/minion -xf - mkdir -p /etc/salt/minion.d printf 'master: 10.0.0.5\nid: jerry' > /etc/salt/minion.d/id.conf %end ``` -------------------------------- ### Install Apache and ensure it is running Source: https://docs.saltproject.io/en/latest/topics/tutorials/states_pt2.html This snippet installs the Apache package and ensures the Apache service is running. It uses a 'require' requisite to ensure the package is installed before starting the service. ```yaml 1apache: 2 pkg.installed: [] 3 service.running: 4 - require: 5 - pkg: apache ``` -------------------------------- ### Login and Authentication Example Source: https://docs.saltproject.io/en/latest/topics/releases/saltapi/0.8.0.html Demonstrates how to log in to the Salt API and retrieve authentication token and permissions. Requires Salt 0.13. ```bash % curl -sS localhost:8000/login \ -H 'Accept: application/x-yaml' -d username='saltdev' -d password='saltdev' -d eauth='pam' return: - eauth: pam expire: 1365508324.359403 perms: - '@wheel' - grains.* - state.* - status.* - sys.* - test.* start: 1365465124.359402 token: caa7aa2b9dbc4a8adb6d2e19c3e52be68995ef4b user: saltdev ``` -------------------------------- ### salt.modules.debian_ip.up Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.debian_ip.html Start up a network interface. ```APIDOC ## salt.modules.debian_ip.up ### Description Start up a network interface. ### Method Salt ### Function up ### Parameters #### Arguments * **iface** (*str) - The name of the interface. * **iface_type** (*str) - The type of the interface (e.g., 'eth'). ### CLI Example ``` salt '*' ip.up eth0 eth ``` ``` -------------------------------- ### Get the latest installed kernel version Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.kernelpkg_linux_apt.html Returns the version of the latest kernel that is currently installed on the system. Note that this may differ from the active kernel if a reboot has not yet occurred after an installation. ```salt salt '*' kernelpkg.latest_installed ``` -------------------------------- ### Verify Packages CLI Examples Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.zypperpkg.html Illustrates how to verify installed packages using the `pkg.verify` command, with options to specify packages and ignore certain file types. ```bash salt '*' pkg.verify ``` ```bash salt '*' pkg.verify httpd ``` ```bash salt '*' pkg.verify 'httpd postfix' ``` ```bash salt '*' pkg.verify 'httpd postfix' ignore_types=['config','doc'] ``` -------------------------------- ### List Installed PowerShell Modules Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_psget.html Lists currently installed PSGet Modules on the system. Use `desc=True` to get verbose descriptions. ```salt salt 'win01' psget.list_modules salt 'win01' psget.list_modules desc=True ``` -------------------------------- ### Example Windows Update Policy Configuration Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.win_lgpo.html This example demonstrates how to write a Salt state file to configure Windows Update settings. It shows the structure required for the `lgpo.set` state, including nested policy settings. ```yaml configure_windows_update_settings: lgpo.set: - computer_policy: Configure Automatic Updates: Configure automatic updating: 3 - Auto download and notify for install Install during automatic maintenance: False Install updates for other Microsoft products: False Scheduled install day: 0 - Every day Scheduled install time: 03:00 ``` -------------------------------- ### Start Instance Source: https://docs.saltproject.io/en/latest/topics/cloud/tencentcloud.html Initiates the startup process for a Tencent Cloud instance. This is used to bring a stopped instance back online. ```bash $ salt-cloud -a start myinstance ``` -------------------------------- ### Get Package Group Differences Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.pacmanpkg.html Lists which of a group's packages are installed and which are not installed. Compatible with yumpkg.group_diff for easy support of state.pkg.group_installed. ```salt salt '*' pkg.group_diff 'xorg' ``` -------------------------------- ### Install Salt Cloud on Ubuntu Source: https://docs.saltproject.io/en/latest/topics/cloud/install/index.html Use these commands to install Salt Cloud on Ubuntu systems by adding the SaltStack PPA and then installing the salt-cloud package. ```bash sudo add-apt-repository ppa:saltstack/salt sudo apt-get update sudo apt-get install salt-cloud ``` -------------------------------- ### Install a Package Source: https://docs.saltproject.io/en/latest/topics/windows/windows-package-manager.html Use `pkg.install` to install a package by its name or full name. You can specify a particular version to install. ```bash # From the master salt winminion pkg.install 'firefox_x64' # From the minion in masterless mode salt-call --local pkg.install "firefox_x64" ``` ```bash # From the master salt winminion pkg.install 'firefox_x64' version=74.0 # From the minion in masterless mode salt-call --local pkg.install "firefox_x64" version=74.0 ``` ```bash # From the master salt winminion pkg.install 'Mozilla Firefox 17.0.1 (x86 en-US)' # From the minion in masterless mode salt-call --local pkg.install "Mozilla Firefox 17.0.1 (x86 en-US)" ``` -------------------------------- ### Create a shortcut with a custom icon and index Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.win_shortcut.html This example demonstrates creating a shortcut and specifying a custom icon file and the index of the icon within that file. This is useful for visually distinguishing shortcuts. ```salt salt '*' shortcut.create 'C:\path\to\shortcut.lnk' 'C:\Windows\notepad.exe' icon_location='C:\path\to\icon.ico' icon_index=2 ``` -------------------------------- ### Version Check Example Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.macpackage.html An example demonstrating how to specify a version check for a package installation. The version number can utilize regular expressions. ```yaml version_check: python --version_check=2.7.[0-9] ``` -------------------------------- ### Install Salt with Mimicked Installation Options Source: https://docs.saltproject.io/en/latest/topics/development/hacking.html Installs Salt from a local clone using a single environment variable that enables custom system paths and version information generation, simplifying the installation process. ```bash MIMIC_SALT_INSTALL=1 pip install --global-option='--salt-root-dir=/path/to/your/virtualenv/' -e ./salt # the path to the salt git clone from above ``` -------------------------------- ### Manage multiple packages from a custom repository Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkg.html This example shows how to manage a custom repository and then install multiple PHP packages from it. The `pkg.installed` state uses the `pkgs` argument to list multiple packages and specifies the repository via `fromrepo`. ```yaml dotdeb.repo: pkgrepo.managed: - name: deb http://packages.dotdeb.org wheezy-php55 all - dist: wheezy-php55 - file: /etc/apt/sources.list.d/dotbeb.list - keyid: 89DF5277 - keyserver: keys.gnupg.net - refresh_db: true php.packages: pkg.installed: - fromrepo: wheezy-php55 - pkgs: - php5-fpm - php5-cli - php5-curl ``` -------------------------------- ### Old Configuration Format Example Source: https://docs.saltproject.io/en/latest/topics/cloud/releases/0.8.7.html An example of the previous configuration format for cloud providers. ```yaml SOMEPROVIDER.option1: some_stuff SOMEPROVIDER.option2: some_other_stuff ``` -------------------------------- ### Install Editable Python Package Source: https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pip_state.html Installs a Python package in 'editable' mode, typically used for development versions from version control systems. This example installs a Django package from a Git repository. ```yaml django-editable: pip.installed: - editable: git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed ``` -------------------------------- ### Install a Package Source: https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.mac_pkgutil.html Installs a .pkg file from a URI or an absolute path. Requires the source path and the package ID. ```salt salt '*' pkgutil.install source=/vagrant/build_essentials.pkg package_id=com.apple.pkg.gcc4.2Leo ``` -------------------------------- ### Install Documentation Dependencies on Ubuntu Source: https://docs.saltproject.io/en/latest/topics/development/contributing.html Installs necessary packages for building Salt documentation on Ubuntu. Ensure you have `imagemagick` installed. ```bash sudo apt-get update sudo apt-get install -y enchant-2 git gcc imagemagick make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev xz-utils inkscape ``` -------------------------------- ### Install Package and Run Service with Requisite (YAML) Source: https://docs.saltproject.io/en/latest/topics/tutorials/starting_states.html This SLS data ensures a package is installed and its corresponding service is running. The 'require' statement guarantees the service starts only after the package installation is successful. ```yaml apache: pkg.installed: [] service.running: - require: - pkg: apache ``` -------------------------------- ### Profile Configuration Example Source: https://docs.saltproject.io/en/latest/topics/cloud/releases/0.8.7.html Example of configuring a profile using the name of a configuration block in the new format. ```yaml rhel-ec2: provider: my-second-ec2 image: ami-e565ba8c size: Micro Instance ``` -------------------------------- ### salt.resources.dummy.package_install Source: https://docs.saltproject.io/en/latest/ref/resources/all/salt.resources.dummy.html Installs a "package" on the current dummy resource. ```APIDOC ## salt.resources.dummy.package_install ### Description Install a "package" on the current dummy resource. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (str) - Required - The name of the package to install. ### Response #### Success Response (200) - **return_value** (None) - Indicates successful installation. ### Request Example ```json { "name": "example-package" } ``` ### Response Example ```json null ``` ``` -------------------------------- ### Full Python State Example Source: https://docs.saltproject.io/en/latest/ref/renderers/all/salt.renderers.py.html A comprehensive example of a Python SLS file defining states for installing 's3cmd' and managing its configuration file. ```python #!py def run(): config = {} if __grains__['os'] == 'Ubuntu': user = 'ubuntu' group = 'ubuntu' home = '/home/{0}'.format(user) else: user = 'root' group = 'root' home = '/root/' config['s3cmd'] = { 'pkg': [ 'installed', {'name': 's3cmd'}, ], } config[home + '/.s3cfg'] = { 'file.managed': [ {'source': 'salt://s3cfg/templates/s3cfg'}, {'template': 'jinja'}, {'user': user}, {'group': group}, {'mode': 600}, {'context': { 'aws_key': __pillar__['AWS_ACCESS_KEY_ID'], 'aws_secret_key': __pillar__['AWS_SECRET_ACCESS_KEY'], }, }, ], } return config ``` -------------------------------- ### Configure Advanced Windows Installer Options in Salt Cloud Source: https://docs.saltproject.io/en/latest/topics/cloud/windows.html Set advanced Windows installation parameters such as delayed service start and custom installation directory within the Salt Cloud provider configuration. ```yaml my-softlayer: driver: softlayer user: MYUSER1138 apikey: 'e3b68aa711e6deadc62d5b76355674beef7cc3116062ddbacafe5f7e465bfdc9' minion: master: saltmaster.example.com win_installer: /root/Salt-Minion-2014.7.0-AMD64-Setup.exe win_delay_start: True win_install_dir: D:\Program Files\Salt Project\Salt win_username: Administrator win_password: letmein smb_port: 445 ```