Saltstack Cheatsheet

Get System Info

  • salt ‘*’ pillar.items
  • salt ‘*’ grains.items

Downgrade a System

git clone git://github.com/saltstack/salt  
cd salt  
git checkout v<version number> 
sudo python setup.py install --force

References

Stack Overflow

Saltstack Cheatsheet

Get System Info

  • salt ‘*’ pillar.items
  • salt ‘*’ grains.items

Downgrade a System

git clone git://github.com/saltstack/salt  
cd salt  
git checkout v&lt;version number&gt; 
sudo python setup.py install --force

References

Stack Overflow

Git Cheatsheet

Roll a Repo Back to a Given Commit

git reset --hard commit_id
git push -f

Find files that have changed in the last 2 days

git log --pretty=format: --name-only --since=&quot;2 days ago&quot; | sort | uniq

View the history of a file

gitk filename

Push a new local branch to a remote Git repo

git push -u origin branch_name

References

Saltstack Cheatsheet

Get System Info

  • salt ‘*’ pillar.items
  • salt ‘*’ grains.items

Downgrade a System

git clone git://github.com/saltstack/salt  
cd salt  
git checkout v<version number> 
sudo python setup.py install --force

References

Stack Overflow

Git Cheatsheet

Roll a Repo Back to a Given Commit

git reset --hard commit_id
git push -f

Find files that have changed in the last 2 days

git log --pretty=format: --name-only --since=&quot;2 days ago&quot; | sort | uniq

View the history of a file

gitk filename

Push a new local branch to a remote Git repo

git push -u origin branch_name

References

Responsive at Last!

It might be a little late to the party, but I finally got around to putting together some responsive stylesheets. This site should now be rocking out on the iPhone like it’s 2007! The old stylesheet scaled well enough, but the updates should hopefully make things a bit more elegant on small screens while at the same time make better use of the additional real estate on larger screens.

Use Netcat to Test Bandwidth

So I needed a handy, low overhead way to test bandwidth between myself and a remote server. SCP was handy and was able to give me a relative thumbs up or down, but the overhead distorted the figures. dd and netcat to the rescue.

Open socket on machine "A"

while [ True ]; do nc -v -l 2222 > ddTest; done

Push a file from machine "B" to machine "A"

dd if=/dev/zero bs=50M count=1 | nc <ip of machine A> 2222

OpsWorks Notes

Finally got a chance to get down and dirty creating Chef recipes for use in OpsWorks. These are primarily just some notes for myself.

Debugging

  • opsworks-agent-cli allows you to view logs, manually run setup scripts, etc
    • not as useful a tool as one might want
    • probably its ability to spit out the entire stack config into a json file is its the most useful feature
    • the show_log log it presents is in /var/lib/aws/opsworks/chef/ if you’d prefer to tail it directly
  • Other logs are in /var/log/aws/opsworks, though I haven’t found those very informative or useful
  • Kudos to a dzone blog post (link below) for help in testing cookbooks. In short, it was much easier to debug the cookbooks from an instance in a dev OpsWorks env:

    1. made my edits to the cookbooks on the dev instance
    2. tested until desired results were achieved
    3. copied the final changes back to my source
    4. committed source to repo for automation use

      cd /opt/aws/opsworks/current/
      opsworks-agent-cli get_json > /tmp/attributes.json
      # edit /tmp/attributes.json as needed
      bin/chef-solo -c conf/solo.rb -j /tmp/attributes.json -o <cookbook::recipe>
      
  • was only able to get "setup" recipes to run, and not "deploy" scripts, when executing a recipe with a "stack command" from the OpsWorks web UI

Resources

sed RE Substitution

For next time I forget…

sed -i .bk -E 's/text to replace (text to keep)/replaced text \1/' file
  • -i: edit the file rather than just stdout the result. A backup of the original is made using the supplied extension
  • -E: support modern regex, as opposed to old or basic regex. Without -E, you’ll have to escape the ()

Each instance of (something) will be treated as a variable which can be called with \#

Software RAID example

For next time I forget…

/sbin/mdadm --create /dev/md1 --chunk=256 --level=raid1 --raid-devices=2 /dev/xvdm /dev/xvdn