Operations grimoire/Deploy with Salt: Difference between revisions

From Nasqueron Agora
(Created page with "== Where to work? == * We deploy from Ysul /opt/nasqueron-operations * You need to belong to the <code>salt</code> group * You want this alias: <code>alias salt sudo -u salt s...")
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Where to work? ==
== Where to work? ==
* We deploy from Ysul /opt/nasqueron-operations
* We deploy from Ysul using:
* You need to belong to the <code>salt</code> group
** /opt/nasqueron-operations as our local copy of rOPS, authoritative for Salt
** /opt/staging for web application content
* You need to belong to the <code>salt</code> group to be able to control Salt
* You need to belong to the <code>deploy</code> group to be able to update /opt/staging (salt is a member of deploy)
* You want this alias: <code>alias salt sudo -u salt salt</code> (tcsh syntax)
* You want this alias: <code>alias salt sudo -u salt salt</code> (tcsh syntax)
* Check salt-master is run, if not <code>service salt-master start</code>
* Check salt-master is run, if not <code>service salt-master start</code>


== Deployment workflow ==
== Deployment workflow ==
# On your laptop, prepare and upload a change to Differential against rOPS repository
=== Apply a new Salt state ===
# On your laptop, prepare and upload a change to Differential against rOPS repository
# Get the change on Ysul: <code>arc patch D607</code>
# Get the change on Ysul: <code>arc patch D607</code>
# Ask Salt to apply the change
# Ask Salt to apply the change
# Log on #nasqueron-operations something like <code>[Eglide] New user account: amj (D607)</code>
# Log on #nasqueron-operations something like <code>[Eglide] New user account: amj (D607)</code>
# Once working, you can merge it to master
# Once working, you can merge it to master
=== Deploy a web site ===
# Commit as needed
# Go to /opt/staging relevant subdirectory and fetch code
# Ask Salt to apply the matching state (if in doubt, a full run is <code>salt '*' state.highstate</code>)


== Salt commands ==
== Salt commands ==
=== Remote server ===
To apply one state or a directory:
To apply one state or a directory:


Line 21: Line 30:
<code>salt eglide state.highstate</code>
<code>salt eglide state.highstate</code>


Replace <code>eglide<code> by the server name, or <code>*</code> to target all machines.
Replace <code>eglide</code> by the server name, or <code>*</code> to target all machines.


When you've a new state, ensure it's called from <code>top.sls<code> file, as the repository root.
When you've a new state, ensure it's called from <code>top.sls</code> file, as the repository root.
 
=== Salt master ===
 
If you wish to deploy directly to the Salt master, replace <code>salt</code> by <code>salt-call --local</code>:
 
<code>salt-call --local state.apply test</code>
 
This should run as root, so the recommended alias is <code>alias salt sudo salt</code> (tcsh syntax)

Revision as of 16:17, 28 April 2017

Where to work?

  • We deploy from Ysul using:
    • /opt/nasqueron-operations as our local copy of rOPS, authoritative for Salt
    • /opt/staging for web application content
  • You need to belong to the salt group to be able to control Salt
  • You need to belong to the deploy group to be able to update /opt/staging (salt is a member of deploy)
  • You want this alias: alias salt sudo -u salt salt (tcsh syntax)
  • Check salt-master is run, if not service salt-master start

Deployment workflow

Apply a new Salt state

  1. On your laptop, prepare and upload a change to Differential against rOPS repository
  2. Get the change on Ysul: arc patch D607
  3. Ask Salt to apply the change
  4.  Log on #nasqueron-operations something like [Eglide] New user account: amj (D607)
  5. Once working, you can merge it to master

Deploy a web site

  1. Commit as needed
  2.  Go to /opt/staging relevant subdirectory and fetch code
  3. Ask Salt to apply the matching state (if in doubt, a full run is salt '*' state.highstate)

Salt commands

Remote server

To apply one state or a directory:

salt eglide state.apply roles/shellserver/users

To apply all:

salt eglide state.highstate

Replace eglide by the server name, or * to target all machines.

When you've a new state, ensure it's called from top.sls file, as the repository root.

Salt master

If you wish to deploy directly to the Salt master, replace salt by salt-call --local:

salt-call --local state.apply test

This should run as root, so the recommended alias is alias salt sudo salt (tcsh syntax)