Orchestration
August 22, 2023 · View on GitHub
Execution Examples
Orchestration Run
The following command does a test orchestration run of
states/orch/web_host.sls:
sudo salt-run state.orchestrate orch.web_host \
pillar='{"tgt_hst":"SERVERNAME", "tgt_pod":"core", "tgt_loc":"us-east-2"}' \
saltenv=timidrobot test=True
pillar=is required- Infrastructure creation is targeted with CLI pillar
(
pillar='{"tgt_hst":"SERVERNAME", "tgt_pod":"core", "tgt_loc":"us-east-2"}')
- Infrastructure creation is targeted with CLI pillar
(
saltenv=is optional- The command above uses Pillars and States from a development environment
(
saltenv=timidrobot). Remove or change tobaseto use production environment.
- The command above uses Pillars and States from a development environment
(
test=is optional- The command above performs a dry run (
test=True). Remove or changed toFalseto apply changes.
- The command above performs a dry run (
Troubleshooting with Salt-Call
Local Render
The following command shows how the SLS is rendered and outputs it as YAML:
states/orch/aws/ec2_instance_web.sls:
sudo salt-call --local --out=yaml state.show_sls orch.aws.ec2_instance_web \
pillar='{"tgt_hst":"SERVERNAME", "tgt_pod":"core", "tgt_loc":"us-east-2"}' \
saltenv=timidrobot
Local Apply
The following command does a local test apply of
states/orch/aws/ec2_instance_web.sls:
sudo salt-call --local --log-level=debug --log-file-level=warning \
state.apply orch.aws.ec2_instance_web \
pillar='{"tgt_hst":"SERVERNAME", "tgt_pod":"core", "tgt_loc":"us-east-2"}' \
saltenv=timidrobot test=True
- Using
salt-callto run individual states can aid in the troubleshooting of orchestration. Thesalt-callcommand above is very verbose and allows errors to be seen in the compiled pillar and state files.
salt-ssh
Per Debugging salt-ssh - Salt SSH, to see errors from a
salt-ssh state or command line invocation:
- Assuming that
orch.bootstrap install salt on minionfailed - Apply the states manually with trace level logging:
sudo salt-ssh index__stage__us-east-2 -l trace --log-file-level=warning --sudo state.apply salt - Search output for
SALT_ARGV - SSH into target machine from
salt-prime(replaceTARGET_IPwith appropriate IP address):sudo ssh -i /root/.ssh/saltstack_rsa_provisioning_20181221 admin@TARGET_IP - Execute
SALT_ARGVcommand from step 2 without'--out jsonand-l quiet
References
AWS
Region Selection
WordPress on AWS
- See
WordPress.md
Cloud-Init
Debian
SaltStack
See ../README.md for information on SaltStack versions and
Best Practices.
Module Documentation
AWS orchestration (including bootstrap) makes use of the boto/boto3 state modules:
Orchestration Documentation
Orchestration Examples
- An example of a complex, multi-host Salt Orchestrate state that performs status checks as it goes (2017-08-11)
- Dynamic Test Servers with Salt | Lincoln Loop (2017-09-12)
- SaltStack as an Alternative to Terraform for AWS Orchestration (2017-08-30, Salt 2017.7.1 was stable version)
- Running Salt States Using Amazon EC2 Systems Manager | AWS Management Tools Blog (2017-07-16, Salt 2016.11.5 was stable version)
Using Salt to boss your clouds around – Anthony Shaw – Medium (2017-05-02, Salt 2016.11.4 was stable version)- Uses salt-cloud, which has far fewer features than the state boto modules
How to Build AWS VPCs with SaltStack Formulas — Six Feet Up (2017-09-19, Salt 2017.7.1 was stable version)- Uses saltstack-formulas/aws-formula, which only adds a layer above a few salt boto state modules.
Boto State Module Examples
- pedrohdz.com/vpc-bootstrap.sls at master · pedrohdz/pedrohdz.com
- confidant/confidant.sls at master · lyft/confidant