Chef Cookbook Dependencies

Adding solver :ruby, :required to your berksfile will help with dependency resolutions

AWS RDS MySQL SSL Connection

This is how we RDS via SSL

In order to connect to AWS RDS MySQL Using SSL, you must first have the AWS CA Cert locally so that you can validate the cert provided by the MySQL Server.

ProTip - SQL Server Snippets

Disable constraints, load data, Enable constraints

Drop all constraint checks, disable triggers, delete all data, enable constraints, enable triggers.

List tables and their sizes

SQL Server - Drop and Recreate FKs Pragmatically

While trying to load a large amount of data into SQL Server I was having an issue trying to truncate tables prior to loading the data, and I was unable to due to some FK constraints. My initial research led me to scripting the removal and creation of the FK constraints, but then i wondered, what if they changed. What if the end user added more that I was unaware of? My search then led me to a blog post where the original author was able to pragmatically backup, drop and recreate the FK Constraints. I modified the script a little to check for the existence of the FK_Details table first before trying to create it.

Once the sql below has run once, the FK_Details table will be populated with the drop_script and create_script columns with the proper SQL commands to create and drop the FKs. Im going to add a time stamp column to track when this was ran. This allows me to add this as part of my maintenance schedule, and track when things are done to the database.

If you want to actually execute on the drop or create, you’ll need to execute EXEC sp_executesql @drop then load your data, and re apply the FKs with EXEC sp_executesql @create;

All credit goes to the original author <- blog post here

ProTip - Linters and more

Below you will find a list of linters I use as well as other atom plugins.

Python

  • linter-python-pep8
  • linter-pylint
  • linter-pycodestyle

Ruby

  • linter-rubocop
  • linter-ruby
  • linter-erb

Chef

  • linter-foodcriic
  • linter-cookstyle
  • language-chef

Terraform

  • linter-terraform-syntax
  • language-terraform

Atom Plugins

ProTip - Am I ready to Commit?

I often would want to submit for a PR, and have comments / other things that need to be addressed before this is ready for a PR. While this is named ‘Am I ready to commit?’ I personally am trying to apply as much of the below as possible. In reality the below should be geared more toward making a PR; but i’m hard on myself and want to ensure each commit is meaningful.

Am I ready to commit?

Did I?

  • Meet all requirements for the Jira task / Issue / Ticket etc.
  • Ensure no linter errors messages
    • Linter messages ignored when applicable
  • Does kitchen converge run successfully?
  • Update README(s) for cookbooks / stacks
    • Add the new function / capability to README(s)
  • Spellcheck / Proofread mrc0der!

Below is a full list, properly named, ‘Am I ready for a PR?’

Am I ready for a PR?

Did I?

  • Meet all requirements for the Jira task / Issue / Ticket etc.
  • Follow any style guides required
  • Bump cookbook version(s)
    • Include new / updated cookbook in env files
  • Bump stacker blueprints version(s)
  • Bump __ version(s)
  • Update cookbooks/metadata.rb
  • Update README(s) for cookbooks / stacks
    • Add the new function / capability to README(s)
  • Spellcheck / Proofread mrc0der!
  • Update .gitignore for any non essential files
  • Did you update the CHANGELOG

Did you double and triple check the above?

  • If so, do it again, chances are you missed something…mrc0der! lol
  • Once that is done, you should be ready to submit your PR.

ProTip - AWS ElasticSearch 5.1 Deployment

When deploying Elasticsearch 5.1 via Cloudformation there are 2 important things to know. Both are Advanced Options for Elasticsearch that are listed as optional, but your CFN stack will FAIL to deploy if they are not set.

Symptoms:
  • In AWS console it will show stack as CREATE_IN_PROGRESS for ~1hr
  • Stack will rollback with ‘Cluster did not stabilize’
  • Same stack with v2.3 will deploy fine…

Im sure by the time someone else finds this post it will be fixed, but if not, see below.

JSON Example -
Yaml Example -

Wordpress - Wordpress plugins to use

Normally I would start one of these things off with STOP! DONT USE WORDPRESS!!!
The fact is, lots do, and lots will continue to do so. Here I will maintain my
list of essential, must haves, and cool to have plugins, mods, or overall config
tips. As with anything you find here, I guarantee NOTHING. With all the NSA / DeepSpace9
0days everything is back-doored / has holes.

Plugins

Wordpress - wpcli Examples

wp plugin install rest-api --activate

wp plugin update --all --allow-root

wp plugin install --allow-root https://github.com/afragen/github-updater/archive/6.2.2.zip --activate

wp plugin install --allow-root https://github.com/wp-sync-db/wp-sync-db/archive/1.5.zip --activate

ProTip - Git Recover Deleted File

Git Checkout Deleted File

Look in git log for deleted file

This will require you scrolling through the git history. If you need you can use a GUI tool. But GUIs are for the weak. cli = power

commit 254b43ad0ceb039a80737919a5e14504b917bbed
Author: username <user@emailfqdn.tld>
Date:   Mon Jan 23 23:34:32 2017 -0800

    site cookbook: style updates; drop legacy site recipe

 delete mode 100644 cookbooks/customer_cookbook/recipes/site.rb

Note the commit id

commit 254b43ad0ceb039a80737919a5e14504b917bbed

Create a new temp branch

git checkout -b pulling_restored_file

Checkout that branch and file

git checkout 254b43ad0ceb039a80737919a5e14504b917bbed^ -- cookbooks/customer_cookbook/recipes/site.rb

Viola!

You should now have the restored file at:

cookbooks/customer_cookbook/recipes/site.rb