### Start Complete Use Cases Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Starts the complete Engine or Beacon use case, including the necessary Salt master and proxy/minion components. Includes an example of triggering an error to test beacon functionality. ```bash # Start Engine use case (master + auto-started proxies) make start-uc-engine # Start Beacon use case (master + minion with beacon sync) make start-uc-beacon # Test Beacon use case by triggering error echo "Critical ERROR occurred" >> /var/log/random.log cat /tmp/random_process_restart.log # Output: Restarting random deamon because of error: Critical ERROR occurred ``` -------------------------------- ### Start Salt Minion Container Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Starts a Salt Minion container that connects to the Salt Master. Minions can be started with a specific name or automatically registered using their container ID. Supports the 'beacon' use case. ```bash # Start minion with specific name make minion-start DEVICE="minion01" # Start minion for Beacon use case make minion-start DEVICE="minion01" UC='beacon' # Start minion without name (uses container ID) make minion-start ``` -------------------------------- ### Start Salt Minion Daemon in Docker Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/MAKEFILE.md This command starts a Salt Minion daemon within a Docker container. It can optionally take a DEVICE argument to name the container and specify its registration name with the Salt Master. If DEVICE is not provided, the container's ID will be used as its hostname for registration. ```makefile make minion-start ``` ```makefile make minion-start DEVICE="" ``` -------------------------------- ### Start Salt Master with Docker Source: https://github.com/juniper/docker-saltstack-junos/blob/master/README.md This snippet demonstrates how to start a Salt Master container using Docker. It provides two methods: using the provided 'make master-start' command, or directly using 'docker run' with specific image and command arguments. The 'docker run' command starts the container in detached mode with debug logging. ```bash root@host# make master-start ``` ```bash #make clean will not work if starting docker like that root@host# docker run -d juniper/saltstack salt-master -l debug ``` -------------------------------- ### Start Salt Master Container Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Starts a Salt Master container, optionally configuring it for the 'engine' or 'beacon' use case. The master automatically accepts minion keys and mounts necessary directories. Can also be started directly using 'docker run'. ```bash # Start Salt Master for Engine use case (default) make master-start # Start Salt Master for Beacon use case make master-start UC='beacon' # Alternative: Start directly via Docker docker run -d juniper/saltstack salt-master -l debug ``` -------------------------------- ### Configure Beacon Event Reactor (YAML) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Creates a SaltStack reactor that responds to beacon events, specifically when a log pattern is detected. This example executes a command to write a message to a log file when an 'ERROR' is found. ```yaml # uc-beacon/reactor/monitor_message.sls {% if data['data']['match'] == 'yes' %} {% set message = data['data']['raw'] %} write_message_to_log: local.cmd.run: - tgt: '*' - arg: - 'echo "Restarting random deamon because of error: {{ message }}" >> /tmp/random_process_restart.log' {% endif %} ``` -------------------------------- ### Verify Proxy Connectivity Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Verifies that Salt proxies are running and can communicate with Junos devices. Includes commands to check proxy process status, ping the master, get proxy status, and execute Junos CLI commands. ```bash # Check if proxy process is running ps -ef | grep proxy01 # Ping master from proxy salt proxy01 status.ping_master saltmaster-engine # Get proxy status salt proxy01 status.all_status # Execute Junos CLI command via proxy salt proxy01 junos.cli "show version" ``` -------------------------------- ### Monitor Salt Events Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Listens to all events on the Salt bus to aid in debugging and verifying event processing. It shows an example of receiving a commit event. ```bash # Inside Salt Master shell salt-run state.event pretty=True # Example output when receiving a commit event: # jnpr/event/proxy01/UI_COMMIT_COMPLETED { # "_stamp": "2016-11-19T13:47:18.223069", # "cmd": "_minion_event", # "data": {...}, # "id": "saltmaster-engine", # "tag": "jnpr/event/proxy01/UI_COMMIT_COMPLETED" # } ``` -------------------------------- ### Listen to SaltStack Events Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/OPERATION.md This command allows you to listen to all events occurring on the Salt Bus in a pretty-printed format. It's invaluable for monitoring system activity and debugging event-driven processes. ```bash salt-run state.event pretty=True ``` -------------------------------- ### Send Test Events with salt-call (Bash) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Demonstrates how to manually trigger events on the Salt bus using the 'salt-call' command. This is useful for testing reactors and automation workflows without waiting for actual device events. ```bash # Example: Triggering a custom event salt-call event.send 'custom/test/event' '{"message": "This is a test"}' ``` -------------------------------- ### Build Docker Image for SaltStack Junos Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Builds the Docker image containing SaltStack, Junos libraries (PyEZ, jxmlease), and all necessary dependencies. Can be built from source using 'make build' or pulled directly from Docker Hub. ```bash # Build from source make build # Or pull from Docker Hub docker pull juniper/saltstack ``` -------------------------------- ### Define Junos Proxy Configuration with SaltStack Pillar Source: https://github.com/juniper/docker-saltstack-junos/blob/master/README.md This snippet shows how to define proxy configurations for Junos devices using SaltStack's Pillar system. It involves creating two files: a top.sls file to map targets to pillar data, and a device-specific sls file to store connection details like host, username, and password. ```bash root@host# cat uc-engine/pillar/top.sls base: proxy01: - proxy01 ``` ```bash root@host# cat uc-engine/pillar/proxy01.sls proxy: proxytype: junos host: 172.17.254.1 username: admin passwd: juniper1 ``` -------------------------------- ### Access Container and Ping Junos Devices with SaltStack Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/OPERATION.md This snippet demonstrates how to enter the main SaltStack container and then use Salt to ping Junos devices. It's useful for initial connectivity checks and device status verification within the SaltStack environment. ```bash make master-shell salt '*' junos.ping ``` -------------------------------- ### Clean Salt Master and Minions Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/MAKEFILE.md This command performs a comprehensive cleanup of the Salt Master and all Salt Minions. It is a convenience command that is equivalent to running 'make master-clean' and 'make minion-clean' sequentially. ```makefile make clean ``` -------------------------------- ### Verify Salt Master and Proxy Status with Docker Source: https://github.com/juniper/docker-saltstack-junos/blob/master/README.md These commands are used to verify that the Salt Master and Junos proxy are running correctly. 'docker ps' lists all running Docker containers, allowing you to check if the 'saltmaster-engine' container is active. The second command, executed within the Salt Master container, lists running processes to confirm that 'proxy01' is operational. ```bash root@host# docker ps ``` ```bash root@saltmaster-engine# ps -ef | grep proxy01 ``` -------------------------------- ### Sync Beacons to Minions Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Synchronizes custom beacon modules from the master to minions and restarts the minions to apply the new beacon configuration. Supports syncing to specific minions or all minions. ```bash # Sync beacons to specific minion make master-sync-beacon DEVICE='minion01' # Or from inside master shell salt "minion01" saltutil.sync_beacons # Restart minion to apply beacon configuration docker restart minion01 ``` -------------------------------- ### Configure Log Beacon (YAML) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Configures a SaltStack beacon to monitor a specified log file for patterns matching a given regex. It defines a beacon named 'log' with a rule to catch error messages. ```yaml # uc-beacon/pillar/log.sls beacons: log: file: /var/log/random.log catch_error_messages: regex: '.*ERROR.*' ``` ```yaml # uc-beacon/docker/master/reactor.conf reactor: - 'salt/beacon/*/log/catch_error_messages': - /srv/reactor/monitor_message.sls ``` -------------------------------- ### Configure Syslog Event Reactor (YAML) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Sets up a SaltStack reactor to respond to specific Syslog events from Junos devices, such as 'UI_COMMIT_COMPLETED'. It defines a trigger for the event and the corresponding Salt state to execute. ```yaml # uc-engine/docker/master/reactor.conf reactor: - 'jnpr/event/*/UI_COMMIT_COMPLETED': - /srv/reactor/junos.sls ``` ```yaml # uc-engine/reactor/junos.sls reachability_check_of_junos_device: local.junos.cli: - tgt: 'proxy01' - arg: - "show version" ``` -------------------------------- ### Configure Junos Device Proxy (YAML) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Defines proxy configuration in pillar files for connecting to Junos devices via NETCONF over SSH on port 830. Includes host, username, and password details. ```yaml # uc-engine/pillar/proxy01.sls proxy: proxytype: junos host: 172.17.254.1 username: admin passwd: juniper1 ``` ```yaml # uc-engine/pillar/top.sls base: proxy01: - proxy01 proxy02: - proxy02 ``` -------------------------------- ### Configure Salt Minion and Send Junos Event Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Configures a Salt minion to use a local master, restarts the master container, accepts all salt keys, and sends a test Junos commit event with associated data. ```bash sed -i "s/^#master: salt/master: saltmaster-engine/" /etc/salt/minion docker restart saltmaster-engine salt-key -yA salt-call event.send 'jnpr/event/proxy01/UI_COMMIT_COMPLETED' \ '{"host": "172.17.254.1", "data": {"severity": 4, "appname": "mgd", "timestamp": "2016-11-17 19:30:14", "hostname": "proxy01", "pid": "84", "priority": 188 }' ``` -------------------------------- ### Manually Generate a SaltStack Event Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/OPERATION.md This command manually sends a custom event to the Salt Bus. It's primarily used for testing SaltStack reactors, allowing you to simulate specific event triggers and observe their behavior. ```bash salt-call event.send 'jnpr/event/dev01/UI_COMMIT_COMPLETED' '{"host": "172.17.0.1", "data": {"severity": 4, "appname": "mgd", "timestamp": "2016-11-11 20:40:44", "hostname": "dev01", "pid": "1584", "priority": 188 }' ``` -------------------------------- ### Clean Up Containers Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Stops and removes Salt containers. Provides commands to clean specific minions, all minions, the master, or all containers. Allows specifying the use case to clean. ```bash # Clean specific minion make minion-clean DEVICE="minion01" # Clean all minions under Engine use case make minion-clean # Clean master make master-clean # Clean everything (master + all minions) make clean # Clean Beacon use case make clean UC='beacon' ``` -------------------------------- ### Access Salt Master Shell Source: https://github.com/juniper/docker-saltstack-junos/blob/master/README.md This command provides a convenient way to access the Salt Master's shell. It is typically executed from the main project directory and allows direct interaction with the Salt Master environment. ```bash root@host# make master-shell ``` -------------------------------- ### Configure Junos Syslog Engine (YAML) Source: https://context7.com/juniper/docker-saltstack-junos/llms.txt Configures the Syslog engine within the Salt Master to receive messages from Junos devices on UDP port 516 and convert them into SaltStack events. Requires Junos device configuration to forward syslog. ```yaml # uc-engine/docker/salt_master.yaml master: localhost engines_dirs: - /srv/engine engines: - junos_syslog: port: 516 auto_accept: True ``` ```bash # Configure Junos device to send syslog to Salt Master # On Junos device: set system services netconf ssh set system syslog host any any commit ``` -------------------------------- ### Stop and Remove Salt Minion Container Source: https://github.com/juniper/docker-saltstack-junos/blob/master/docs/MAKEFILE.md This command stops and removes a Salt Minion Docker container. You can specify a particular container using the DEVICE argument (either by name or container ID), or omit it to remove all Salt Minion containers. Attached volumes and files are not deleted. ```makefile make minion-clean DEVICE="" ``` ```makefile make minion-clean ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.