Class: Cheftacular::StatelessActionDocumentation

Inherits:
Object
  • Object
show all
Defined in:
lib/cheftacular/stateless_action.rb,
lib/cheftacular/stateless_actions/rvm.rb,
lib/cheftacular/stateless_actions/help.rb,
lib/cheftacular/stateless_actions/pass.rb,
lib/cheftacular/stateless_actions/cloud.rb,
lib/cheftacular/stateless_actions/slack.rb,
lib/cheftacular/stateless_actions/backups.rb,
lib/cheftacular/stateless_actions/service.rb,
lib/cheftacular/stateless_actions/test_env.rb,
lib/cheftacular/stateless_actions/arguments.rb,
lib/cheftacular/stateless_actions/fetch_file.rb,
lib/cheftacular/stateless_actions/update_tld.rb,
lib/cheftacular/stateless_actions/client_list.rb,
lib/cheftacular/stateless_actions/disk_report.rb,
lib/cheftacular/stateless_actions/environment.rb,
lib/cheftacular/stateless_actions/get_pg_pass.rb,
lib/cheftacular/stateless_actions/knife_upload.rb,
lib/cheftacular/stateless_actions/reinitialize.rb,
lib/cheftacular/stateless_actions/restart_swap.rb,
lib/cheftacular/stateless_actions/upload_nodes.rb,
lib/cheftacular/stateless_actions/upload_roles.rb,
lib/cheftacular/stateless_actions/remove_client.rb,
lib/cheftacular/stateless_actions/server_update.rb,
lib/cheftacular/stateless_actions/chef_bootstrap.rb,
lib/cheftacular/stateless_actions/compile_readme.rb,
lib/cheftacular/stateless_actions/create_git_key.rb,
lib/cheftacular/stateless_actions/full_bootstrap.rb,
lib/cheftacular/stateless_actions/clean_cookbooks.rb,
lib/cheftacular/stateless_actions/cloud_bootstrap.rb,
lib/cheftacular/stateless_actions/fix_known_hosts.rb,
lib/cheftacular/stateless_actions/get_haproxy_log.rb,
lib/cheftacular/stateless_actions/chef_environment.rb,
lib/cheftacular/stateless_actions/get_log_from_bag.rb,
lib/cheftacular/stateless_actions/cleanup_log_files.rb,
lib/cheftacular/stateless_actions/compile_audit_log.rb,
lib/cheftacular/stateless_actions/add_ssh_key_to_bag.rb,
lib/cheftacular/stateless_actions/replication_status.rb,
lib/cheftacular/stateless_actions/clean_sensu_plugins.rb,
lib/cheftacular/stateless_actions/update_split_branches.rb,
lib/cheftacular/stateless_actions/clean_server_passwords.rb,
lib/cheftacular/stateless_actions/check_cheftacular_settings.rb,
lib/cheftacular/stateless_actions/get_active_ssh_connections.rb,
lib/cheftacular/stateless_actions/initialize_data_bag_contents.rb,
lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap.rb,
lib/cheftacular/stateless_actions/update_cloudflare_dns_from_cloud.rb,
lib/cheftacular/stateless_actions/get_shorewall_allowed_connections.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, config) ⇒ StatelessActionDocumentation

Returns a new instance of StatelessActionDocumentation.



4
5
6
# File 'lib/cheftacular/stateless_action.rb', line 4

def initialize options, config
  @options, @config = options, config
end

Instance Method Details

#add_ssh_key_to_bagObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/add_ssh_key_to_bag.rb', line 4

def add_ssh_key_to_bag
  @config['documentation']['stateless_action'] <<  [
    "`cft add_ssh_key_to_bag \"<NEW SSH PUB KEY>\" [SPECIFIC_REPOSITORY]` this command will add the given ssh key to the default authentication data bag. " +
    "After this your server recipes should read the contents of the 'default' 'authentication' bag for the authorized_keys array.",

    [
      "    1. `SPECIFIC_REPOSITORY` is a special argument, if left blank the key will be placed in the authorized_keys array in the bag, otherwise it will " +
      "be placed in the specific_authorized_keys hash under a key named for the repository that is passed. The script will error if SPECIFIC_REPOSITORY " +
      "does not exist in the cheftacular.yml respositories hash. You can then use this data to give users selective ssh access to certain servers."
    ]
  ]
end

#argumentsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cheftacular/stateless_actions/arguments.rb', line 3

def arguments
  @config['documentation']['arguments'] <<  [
    '## Arguments and flags for cheftacular',

    '### Environment flags',

    '1.  `-d|--dev-remote` toggles on dev-remote mode. Commands passed to cft will hit the devremote server(s) instead of the default server(s)',

    '2.  `--env ENV` sets the environment commands hit to one you specify instead of the default one.',

    '3.  `-p|--prod` toggles on production mode. Commands passed to cft will hit the production server(s) instead of the default server(s)',

    '4.  `-Q|--qa` toggles on QA mode. Commands passed to cft will hit the QA server(s) instead of the default server(s)',

    '5.  `-s|--staging` toggles on staging mode. Commands passed to cft will hit the staging server(s) instead of the default server(s)',

    '6.  `--split-env SPLIT_ENV_NAME` sets the sub-environment to SPLIT_ENV_NAME. This only slightly affects certain commands.',

    '7.  `-t|--test` toggles on test mode. Commands passed to cft will hit the test server(s) instead of the default server(s)',

    '### General Flags',

    '1.  `-a|--address ADDRESS` will force the command to only run against the specified address if it belongs to a node',

    '2.  `-D|--debug` toggles on extremely verbose logging. Chef-client runs will generate ~10 times the amounts of logs including any additional effects that the `-v` flag will activate',

    '3. `--no-logs` will make the cft commands not generate log files, you must still specify `-v` if you want output of most verbose commands to your terminal.',

    '4.  `-n|--node-name NODE_NAME` will force the command to only run against the specified name if it belongs to a node',

    '5.  `-q|--quiet` will make the cft commands only output information that is a direct result of the command being run',

    "6.  `-r|--role-name ROLE_NAME` will force the command to only run against the specified role if it exists (this argument is generally not needed though it can be used to deploy a codebase for an application you're not currently cd'd into when running this as a gem)",

    '7.  `-R|--repository NAME` will make the command run against a specific repository or context (automatically set for application mode)',

    '8.  `-v|--verbose` toggles on verbose logging. All commands that write logs will also output to terminal AND write the logs.',

    '### Help Related',

    '1. `-h|--help` Displays the full readme and exits.',

    '### Action Flags',

    '1.  `-e|--except-role ROLE_NAME` will *prevent* any server with this role from being *deployed to* for the deploy command. Other commands will ignore this argument.',

    '2.  `-z|--unset-revision` will unset a custom revision specified in the arg below and make the codebase utilize the default.',

    "3.  `-Z|--revision REVISION` will force the role you're deploying to to utilize the revision specified here. This can be a specific commit, a branch name or even a tag.",

    '    1. Note: The system does not check if the revision exists, if you pass a non-existent revision no one will be able to deploy to that role until -Z with a correction revision or -z is passed.'
  ]
end

#backupsObject



4
5
6
7
8
9
10
11
12
# File 'lib/cheftacular/stateless_actions/backups.rb', line 4

def backups
  @config['documentation']['stateless_action'] <<  [
    "`cft backup [activate|deactivate]` this command " +
    "sets the fetch_backups and restore_backups flags in your config data bag for an environment. " +
    "These can be used to give application developers a way to trigger / untrigger restores in an environment"
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#check_cheftacular_settingsObject



4
5
6
# File 'lib/cheftacular/stateless_actions/check_cheftacular_settings.rb', line 4

def check_cheftacular_settings
  #TODO

end

#chef_bootstrapObject



4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/chef_bootstrap.rb', line 4

def chef_bootstrap
  @config['documentation']['stateless_action'] <<  [
    "`cft chef_bootstrap ADDRESS NODE_NAME` allows you to register a node in the chef system, " + 
    "remove any lingering data that may be associated with it and update the node's runlist if it has an entry in nodes_dir for its NODE_NAME."
  ]
end

#chef_environmentObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/cheftacular/stateless_actions/chef_environment.rb', line 3

def chef_environment
  @config['documentation']['stateless_action'] <<  [
    "[NYI]`cft chef_environment ENVIRONMENT_NAME [create|destroy]` will allow you to interact with chef environments on the chef server.",
  
    [
      "    1.  `create` will create an environment if it does not exist.",

      "    2.  `destroy` will destroy a chef environment *IF IT HAS NO NODES*"
    ]
  ]
end

#clean_cookbooksObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/clean_cookbooks.rb', line 4

def clean_cookbooks
  @config['documentation']['stateless_action'] <<  [
    "`cft clean_cookbooks [force] [remove_cookbooks]` allows you to update the internal chef-repo's cookbooks easily. " +
    "By default this script will force you to decide what to do with each cookbook individually (shows version numbers and whether to overwrite it to cookbooks or not).",

    [
      "    1. `force` argument will cause the downloaded cookbooks to *always* overwrite the chef-repo's cookbooks as long as the downloaded cookbook has a higher version number.",

      "    2. If you would like to remove all the cookbooks on the chef server, run `knife cookbook bulk delete '.*' -p -c ~/.chef/knife.rb`"
    ]
  ]
end

#clean_sensu_pluginsObject



3
4
5
6
7
8
# File 'lib/cheftacular/stateless_actions/clean_sensu_plugins.rb', line 3

def clean_sensu_plugins
  @config['documentation']['stateless_action'] <<  [
    "[NYI]`cft clean_sensu_plugins` will checkout / update the sensu community plugins github repo on your " +
    "local machine and sync any sensu plugin files in your wrapper cookbook directory with what is in the repo."
  ]
end

#clean_server_passwordsObject



4
5
6
# File 'lib/cheftacular/stateless_actions/clean_server_passwords.rb', line 4

def clean_server_passwords

end

#cleanup_log_filesObject



4
5
6
# File 'lib/cheftacular/stateless_actions/cleanup_log_files.rb', line 4

def cleanup_log_files

end

#client_listObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cheftacular/stateless_actions/client_list.rb', line 4

def client_list
  @config['documentation']['stateless_action'] <<  [
    "`cft client_list` Allows you check the basic information for all the servers setup via chef. " +
    "Shows the server's short name, its public ip address and roles (run_list) by default.",

    [
      "    1. `-v` option will make this command display the server's domain name, " +
      "whether its password is stored on the chef server and what that password is.",

      "    2. `-W|--with-priv` option will make this command display the server's local (private) ip address. " + 
      "This address is also the server's `local.<SERVER_DNS_NAME>`.",

      "    3. This command is aliased to `client-list` with no arguments or cft prefix."
    ]
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#cloudObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cheftacular/stateless_actions/cloud.rb', line 4

def cloud
  @config['documentation']['stateless_action'] <<  [
    "`cft cloud <FIRST_LEVEL_ARG> [<SECOND_LEVEL_ARG>[:<SECOND_LEVEL_ARG_QUERY>]*] ` this command handles talking to various cloud APIs. " +
    "If no args are passed nothing will happen.",

    [
      "    1. `domain` first level argument for interacting with cloud domains",

      "        1. `list` default behavior",

      "        2. `read:TOP_LEVEL_DOMAIN` returns detailed information about all subdomains attached to the TOP_LEVEL_DOMAIN",

      "        3. `read_record:TOP_LEVEL_DOMAIN:QUERY_STRING` queries the top level domain for all subdomains that have the QUERY_STRING in them.",

      "        4. `create:TOP_LEVEL_DOMAIN` creates the top level domain on rackspace",

      "        5. `create_record:TOP_LEVEL_DOMAIN:SUBDOMAIN_NAME:IP_ADDRESS[:RECORD_TYPE[:TTL]]` " + 
      "IE: `cft cloud domain create:mydomain.com:myfirstserver:1.2.3.4` will create the subdomain 'myfirstserver' on the mydomain.com domain.",

      "        6. `destroy:TOP_LEVEL_DOMAIN` destroys the top level domain and all of its subdomains",

      "        7. `destroy_record:TOP_LEVEL_DOMAIN:SUBDOMAIN_NAME` deletes the subdomain record for TOP_LEVEL_DOMAIN if it exists.",

      "        8. `update:TOP_LEVEL_DOMAIN` takes the value of the email in the authentication data bag for your specified cloud and updates the TLD.",

      "        9. `update_record:TOP_LEVEL_DOMAIN:SUBDOMAIN_NAME:IP_ADDRESS[:RECORD_TYPE[:TTL]]` similar to `create_record`.",

      "    2. `server` first level argument for interacting with cloud servers, " +
      "if no additional args are passed the command will return a list of all servers on the preferred cloud.",

      "        1.  `list` default behavior",

      "        2. `read:SERVER_NAME` returns all servers that have SERVER_NAME in them (you want to be as specific as possible for single matches)",

      "        3. `create:SERVER_NAME:FLAVOR_ALIAS` IE: `cft cloud server \"create:myserver:1 GB Performance\"` " +
      "will create a server with the name myserver and the flavor \"1 GB Performance\". Please see flavors section.",

      "            1. NOTE! If you forget to pass in a flavor alias the script will not error! It will attempt to create a 512MB Standard Instance!",

      "            2. NOTE! Most flavors have spaces in them, you must use quotes at the command line to utilize them!",

      "        4. `destroy:SERVER_NAME` destroys the server on the cloud. This must be an exact match of the server's actual name or the script will error.",

      "        5. `poll:SERVER_NAME` polls the cloud's server for the status of the SERVER_NAME. This command " +
      "will stop polling if / when the status of the server is ACTIVE and its build progress is 100%.",

      "        6. `attach_volume:SERVER_NAME:VOLUME_NAME[:VOLUME_SIZE[:DEVICE_LOCATION]]` " +
      "If VOLUME_NAME exists it will attach it if it is unattached otherwise it will create it",

      "            1. NOTE! If the system creates a volume the default size is 100 GB!",

      "            2. DEVICE_LOCATION refers to the place the volume will be mounted on, a place like `/dev/xvdb`, " +
      "from here it must be added to the filesystem to be used.",

      "            3. If you want to specify a location, you must specify a size, if the volume already exists it wont be resized but will be attached at that location!",

      "            4. If DEVICE_LOCATION is blank the volume will be attached to the first available slot.",

      "        7. `detach_volume:SERVER_NAME:VOLUME_NAME` Removes the volume from the server if it is attached. " +
      "If this operation is performed while the volume is mounted it could corrupt the volume! Do not do this unless you know exactly what you're doing!",

      "        8. `list_volumes:SERVER_NAME` lists all volumes attached to a server",

      "        9. `read_volume:SERVER_NAME:VOLUME_NAME` returns the data of VOLUME_NAME if it is attached to the server.",

      "    3. `volume` first level argument for interacting with cloud storage volumes, if no additional args are passed the command will return a list of all cloud storage containers.",
        
      "        1. `list` default behavior",

      "        2. `read:VOLUME_NAME` returns the details for a specific volume.",

      "        3. `create:VOLUME_NAME:VOLUME_SIZE` IE `cft rax volume create:staging_db:256`",

      "        4. `destroy:VOLUME_NAME` destroys the volume. This operation will not work if the volume is attached to a server.",

      "    4. `flavor` first level argument for listing the flavors available on the cloud service",

      "        1. `list` default behavior",

      "        2. `read:FLAVOR SIZE` behaves the same as list unless a flavor size is supplied.",

      "            1. Standard servers are listed as XGB with no spaces in their size, performance servers are listed as X GB with " +
      "a space in their size. If you are about to create a server and are unsure, query flavors first."
    ]
  ]
end

#cloud_bootstrapObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cheftacular/stateless_actions/cloud_bootstrap.rb', line 4

def cloud_bootstrap
  @config['documentation']['stateless_action'] <<  [
    "`cft cloud_bootstrap NODE_NAME FLAVOR_NAME [DESCRIPTOR] [--with-dn DOMAIN]` uses a cloud api to " +
    "create a server and attaches its DOMAIN_NAME to the TLD specified for that environment (IE: example-staging.com for staging)",

    [
      "    1. If no DOMAIN_NAME is supplied it will use the node's NODE_NAME (IE: api01.example-staging.com)",

      "    2. If the `--with-dn DOMAIN` argument is supplied the rax api will attempt to attach the node to the " +
      "top level domain instead of the default environment one. This tld must be attached to the cloud service. "+
      "This also allows you to attach to custom subdomains instead of NODE_NAME.ENV_TLD",

      "    3. `cft cloud_bootstrap myserver \"1 GB Performance\" --with-dn myserver.example-staging.com` " +
      'The "1 GB Perfomance" does not have to be exact, "1 GB" will match "1 GB Performance" and "1GB" ' +
      "will match \"1GB Standard\" (for rackspace flavors)",

      "    4. DESCRIPTOR is used as an internal tag for the node, if left blank it will become the name of the node. " +
      "It is recommended to enter a custom repository-dependent tag here to make nodes easier to load-balance like \"lb:[CODEBASE_NAME]\""
    ]
  ]
end

#compile_audit_logObject



3
4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/compile_audit_log.rb', line 3

def compile_audit_log
  @config['documentation']['stateless_action'] <<  [
    "`cft compile_audit_log [clean]` compiles the audit logs in each environment's " +
    "audit data bag a audit-log-CURRENTDAY.md file in the log folder of the application. Bear in mind that the bag " +
    "can only hold 100K bytes and will need to have that data removed to store more than that."
  ]
end

#compile_readmeObject



3
4
5
6
7
# File 'lib/cheftacular/stateless_actions/compile_readme.rb', line 3

def compile_readme
  @config['documentation']['stateless_action'] <<  [
    "`cft compile_readme` compiles all documentation methods and creates a README.md file in the log folder of the application."
  ]
end

#create_git_keyObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/create_git_key.rb', line 3

def create_git_key
  @config['documentation']['stateless_action'] <<  [
    "`cft create_git_key ID_RSA_FILE [OAUTH_TOKEN]` This command will update the default/authentication data bag with new credentials. " +
    "The [ID_RSA_FILE](https://help.github.com/articles/generating-ssh-keys) needs to exist beforehand.",

    [
      "    1. This command will upload both the private and public key to the data bag. " +
      "The public key should be the one that matches the github user for your deployment github user.",

      "    2. `OAUTH_TOKEN` *must* be generated by logging into github and generating an access token in the account settings -> applications -> personal access tokens"
    ]
  ]
end

#disk_reportObject



3
4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/disk_report.rb', line 3

def disk_report
  @config['documentation']['stateless_action'] <<  [
    "`cft disk_report` will fetch useful statistics from every server for every environment and output it into your log directory."
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#environmentObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cheftacular/stateless_actions/environment.rb', line 4

def environment
  @config['documentation']['stateless_action'] <<  [
    "`cft environment boot|destroy` will boot / destroy the current environment",

    [
      "    1. `boot` will spin up servers and bring them to a stable state. " +
      "This includes setting up their subdomains for the target environment.",

      "    2. `destroy` will destroy all servers needed for the target environment",

      "    3. This command will prompt when attempting to destroy servers in staging or production"
    ]
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#fetch_fileObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/fetch_file.rb', line 3

def fetch_file
  @config['documentation']['stateless_action'] <<  [
    "[NYI]`cft fetch_file NODE_NAME LOCATION_ALIAS FILE_NAME` fetches a file from the remote node. ",

    [
      "    1. `LOCATION_ALIAS` will be parsed as a path if it has backslash characters. Otherwise it will be parsed from your " +
      "location_aliases hash in your cheftacular.yml",

      "    2. `FILE_NAME` is the actual name of the file to be fetched. If no value is passed or the file does not exist in the " +
      "LOCATION_ALIAS, the command will return the entries in LOCATION_ALIAS"
    ]
  ]
end

#fix_known_hostsObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/fix_known_hosts.rb', line 4

def fix_known_hosts
  @config['documentation']['stateless_action'] <<  [
    "`cft fix_known_hosts [HOSTNAME]` this command will delete entries in your known_hosts file " +
    "for all the servers that are in our system (ip addresses AND dns names)",

    [
      "    1. Passing in a hostname will make the command only remove entries with that hostname / ip specifically"
    ]
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#full_bootstrapObject



4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/full_bootstrap.rb', line 4

def full_bootstrap
  @config['documentation']['stateless_action'] <<  [
    "`cft full_bootstrap ADDRESS ROOT_PASS NODE_NAME` This command performs both " +
    "#{ @config['cheftacular']['preferred_cloud_os'] }_bootstrap and chef_bootstrap."
  ]
end

#get_active_ssh_connectionsObject



3
4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/get_active_ssh_connections.rb', line 3

def get_active_ssh_connections
  @config['documentation']['stateless_action'] <<  [
    "`cft get_active_ssh_connections` will fetch the active ssh connections from every server and output it into your log directory."
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#get_haproxy_logObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/get_haproxy_log.rb', line 4

def get_haproxy_log
  @config['documentation']['stateless_action'] <<  [
    "`cft get_haproxy_log` this command will generate a haproxy html file for the load balancer(s) associated with a repository in the log directory. " +
    "Opening this log file in the browser will show the status of that haproxy at the time of the log. ",

    [
      "    1. In devops mode, this command will not do anything without the -R repository passed."
    ]
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#get_log_from_bagObject



4
5
6
7
8
9
10
11
# File 'lib/cheftacular/stateless_actions/get_log_from_bag.rb', line 4

def get_log_from_bag
  @config['documentation']['stateless_action'] <<  [
    "`cft get_log_from_bag <NODE_NAME-COMMAND_TYPE>` this command grabs the latest command run log from the data bags " +
    "and saves it to your log directory. There are different types of logs saved per server depending on command."
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#get_pg_passObject



4
5
6
7
8
9
10
11
# File 'lib/cheftacular/stateless_actions/get_pg_pass.rb', line 4

def get_pg_pass
  @config['documentation']['stateless_action'] <<  [
    "`cft get_pg_pass ['clip']` command will output the current environment's pg_password to your terminal. " +
    "Optionally you can pass in clip like `cft get_pg_pass clip` to have it also copy the pass to your clipboard."
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#get_shorewall_allowed_connectionsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cheftacular/stateless_actions/get_shorewall_allowed_connections.rb', line 3

def get_shorewall_allowed_connections
  @config['documentation']['stateless_action'] <<  [
    "`cft get_shorewall_allowed_connections [PATH_TO_LOCAL_FILE] -n NODE_NAME` command will query a single server and return all of its ACCEPT connections " +
    "from shorewall in it's syslog and return the results in a CSV format. Useful for tracking IP activity.",

    [
      "    1. You must pass in a node name to query with `-n NODE_NAME`",

      "    2. This command will attempt to `dig` each ip address to give you the most likely culprit.",

      "    3. If `PATH_TO_LOCAL_FILE` is not blank, the command will use that file instead of building a file on the remote server"
    ]
  ]
end

#helpObject



3
4
5
6
7
8
9
10
11
# File 'lib/cheftacular/stateless_actions/help.rb', line 3

def help
  @config['documentation']['stateless_action'] <<  [
    "`cft help COMMAND|MODE` this command returns the documentation for a specific command if COMMAND matches the name of a command. " +
    "Alternatively, it can be passed `action|arguments|application|current|devops|stateless_action` to fetch the commands for a specific mode." +
    "Misspellings of commands will display near hits."
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#initialize_data_bag_contentsObject



3
4
5
6
7
8
# File 'lib/cheftacular/stateless_actions/initialize_data_bag_contents.rb', line 3

def initialize_data_bag_contents
  @config['documentation']['stateless_action'] <<  [
    "`cft initialize_data_bag_contents ENVIRONMENT_NAME` will ensure the data bags always have the correct structure before each run. " +
    "This command is run every time the gem is started and if called directly, will exit after completion."
  ]
end

#knife_uploadObject



4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/knife_upload.rb', line 4

def knife_upload
  @config['documentation']['stateless_action'] <<  [
    "`cft knife_upload` will resync the chef-server with the local chef-repo code. " + 
    "This command is analog for `knife upload /`"
  ]
end

#passObject



4
5
6
7
8
9
10
11
# File 'lib/cheftacular/stateless_actions/pass.rb', line 4

def pass
  @config['documentation']['stateless_action'] <<  [
    "`cft pass NODE_NAME` will drop the server's sudo password into your clipboard. " +
    "Useful for when you need to ssh into the server itself and try advanced linux commands"
  ]

  @config['documentation']['application'] << @config['documentation']['stateless_action'].last
end

#reinitializeObject



4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/reinitialize.rb', line 4

def reinitialize
  @config['documentation']['action'] <<  [
    "`cft reinitialize IP_ADDRESS NODE_NAME` will reconnect a server previously managed by chef to a new chef server. " +
    "The node name MUST MATCH THE NODE'S ORIGINAL NODE NAME for the roles to be setup correctly."
  ]
end

#remove_clientObject



4
5
6
7
8
9
10
# File 'lib/cheftacular/stateless_actions/remove_client.rb', line 4

def remove_client
  @config['documentation']['stateless_action'] <<  [
    "`cft remove_client -n NODE_NAME` removes a client (and its node data) from the chef-server. " +
    "It also removes its dns records from the cloud service (if possible). " +
    "This should not be done lightly as you will have to wipe the server and trigger another chef-client run to get it to register again"
  ]
end

#replication_statusObject



4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/replication_status.rb', line 4

def replication_status
  @config['documentation']['stateless_action'] <<  [
    "`cft replication_status` will check the status of the database master and slaves in every environment. " +
    "Also lists how far behind the slaves are from the master in milliseconds."
  ]
end

#restart_swapObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/cheftacular/stateless_actions/restart_swap.rb', line 3

def restart_swap
  @config['documentation']['stateless_action'] <<  [
    "`cft restart_swap` will restart the swap on every server that doesn't have swap currently on. " +
    "Useful if you notice servers with no swap activated from `cft disk_report`",

    [
      "    1. There is no risk in running this command. Sometimes swap doesnt reactivate if " +
      "the server was rebooted and this command fixes that."
    ]
  ]
end

#rvmObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cheftacular/stateless_actions/rvm.rb', line 4

def rvm
  @config['documentation']['stateless_action'] <<  [
    "`cft rvm [COMMAND] [ADDITIONAL_COMMANDS]*` will run rvm commands on the remote servers. " +
    "Output from this command for each server will go into your rvm directory under the log directory. " +
    "Please refer to [the rvm help page](https://rvm.io/rvm) for more information on rvm commands.",

    [
      "    1. When no commands are passed, rvm will just run `rvm list` on each server on all servers in " +
      "the current environment.",

      "    2. When `list|list_rubies` is passed, rvm will run `rvm list rubies` on all servers in the " +
      "current environment.",

      "    3. When `install RUBY_TO_INSTALL` is passed, rvm will attempt to install that ruby on each " +
      "system in the current environment. It is a good idea to use strings like ruby-2.2.1",

      "    4. `run [RVM_COMMANDS]+` will run the rest of the arguments as a complete rvm command. An example " +
      "of this being `cft rvm run gemset update`. This will run on all servers in the current environment.",

      "    5. `all_environments [RVM_COMMANDS]+` will run the rest of the arguments as a complete rvm command " +
      "*on all of the servers in every environment*.",

      "    6. `test [RVM_COMMANDS]+` will run the rest of the arguments as a complete rvm command with scoping. " +
      "By default, rvm commands run against all servers in the environment but with test you can pass -n NODE_NAME " +
      " or -r ROLE_NAME flags to scope the servers the rvm command will be run on. Useful for testing.",

      "    7. `upgrade_rvm` will run `rvm get stable --auth-dotfiles` on all servers for the current environment. " +
      "It will also check and attempt to upgrade pre 1.25 installations of RVM to 1.26+ (which requires a GPG key)."
    ]
  ]
end

#server_updateObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cheftacular/stateless_actions/server_update.rb', line 4

def server_update
  @config['documentation']['stateless_action'] <<  [
    "`cft server_update [restart]` allows you to force update all nodes' packages for a specific environment. " + 
    "This should be done with caution as this *might* break something.",

    [
      "    1. `hip apt_update restart` will prompt to ask if you also want to restart all servers in a rolling restart. " +
      "This should be done with extreme caution and only in a worst-case scenario."
    ]
  ]
end

#serviceObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cheftacular/stateless_actions/service.rb', line 4

def service
  @config['documentation']['stateless_action'] <<  [
    "`cft service [COMMAND] [SERVICE]` will run service commands on remote servers. " +
    "This command only runs on the first server it comes across. Specify others with -n NODE_NAME.",

    [
      "    1. When no commands are passed, the command will list all the services in the /etc/init directory",

      "    2. When `list` is passed, the above behavior is performed ",

      "    3. When `restart|stop|start SERVICE` is passed, the command will attempt to restart|stop|start the " + 
      "service if it has a .conf file on the remote server in the /etc/init directory."
    ]
  ]
end

#slackObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cheftacular/stateless_actions/slack.rb', line 3

def slack
  @config['documentation']['stateless_action'] <<  [
    "`cft slack \"MESSAGE\" [CHANNEL]` will attempt to post the message to the webhook set in your cheftacular.yml. " +
    "Slack posts to your default channel by default but if the CHANNEL argument is supplied the message will post there.",

    [
      "    1. NOTE: To prevent confusing spam from many possible sources, the username posted to slack will always be " +
      "*Cheftacular*. This can be overloaded in the StatelessAction method \"slack\" but this is not recommended.",

      "    2. Remember, if you have auditing turned on in your cheftacular.yml, you can track who sends what to slack."
    ]
  ]
end

#test_envObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cheftacular/stateless_actions/test_env.rb', line 4

def test_env
  @config['documentation']['stateless_action'] <<  [
    "`cft test_env [TARGET_ENV] boot|destroy` will create (or destroy) the test nodes for a particular environment " +
    "(defaults to staging, prod split-envs can be set with `-p`). Please read below for how TARGET_ENV works",

    [
      "    1. TARGET_ENV changes functionality depending on the overall (like staging / production) environment",

      "        1. In staging, it cannot be set and defaults to split (splitstaging).",

      "        2. In production, it can be splita, splitb, splitc, or splitd.",

      "        3. The default tld used should change depending on which environment you are booting / destroying. " +
      "This is set in the environment's config data bag under the tld key"
    ]
  ]
end

#ubuntu_bootstrapObject



3
4
5
6
7
8
9
# File 'lib/cheftacular/stateless_actions/bootstrappers/ubuntu_bootstrap.rb', line 3

def ubuntu_bootstrap
  @config['documentation']['stateless_action'] <<  [
    "`cft ubuntu_bootstrap ADDRESS ROOT_PASS` This command will bring a fresh server to a state " +
    "where chef-client can be run on it via `cft chef-bootstrap`. It should be noted that it is in "+
    "this step where a server's randomized deploy_user sudo password is generated."
  ]
end

#update_cloudflare_dns_from_cloudObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cheftacular/stateless_actions/update_cloudflare_dns_from_cloud.rb', line 3

def update_cloudflare_dns_from_cloud
  @config['documentation']['stateless_action'] <<  [
    "`cft update_cloudflare_dns_from_cloud [skip_update_tld]` command will force a full dns update for cloudflare. ",

    [
      "    1. It will ensure all the subdomain entries are correct (based on the contents of the addresses data bag) " +
      "and update them if they are not. It will also create the local subdomain for the entry as well if it " +
      "does exist and point it to the correct private address for an environment.",

      "    2. This command will also ensure any dns records on your cloud are also migrated over to cloudflare as well. " +
      "This also includes the reverse in the event you would like to turn off cloudflare.",

      "    3. The argument `skip_update_tld` will stop the long process of checking and updating all the server domains " +
      "_before_ cloudflare is updated. Only skip if you believe your domain info on your cloud is accurate."
    ]
  ]
end

#update_split_branchesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cheftacular/stateless_actions/update_split_branches.rb', line 4

def update_split_branches
  @config['documentation']['stateless_action'] <<  [
    "`cft update_split_branches` will perform a series of git commands that will merge all the " +
    "split branches for your split_branch enabled repositories with what is currently on master and push them.",

    [
      "    1. Repository must be set with `-R REPOSITORY_NAME` for this command to work.",

      "    2. Attempting to run this command in other repositories that do not have the branches listed " +
      "in run_list_environments OR do not have split_branch set to true will raise an error.",

      "    3. This command will only succeed *IF THERE ARE NO MERGE CONFLICTS*.",

      "    4. This command will return a helpful error statement if you attempt to run the command " + 
      "with changes to your current working directory. You must commit these changes before running this command."
    ]
  ]
end

#update_tldObject



3
4
5
6
7
8
9
10
# File 'lib/cheftacular/stateless_actions/update_tld.rb', line 3

def update_tld
  @config['documentation']['stateless_action'] <<  [
    "`cft update_tld TLD` command will force a full dns update for a tld in the preferred cloud. " +
    "It will ensure all the subdomain entries are correct (based on the contents of the addresses data bag) " +
    "and update them if they are not. It will also create the local subdomain for the entry as well if it " +
    "does exist and point it to the correct private address."
  ]
end

#upload_nodesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cheftacular/stateless_actions/upload_nodes.rb', line 4

def upload_nodes
  @config['documentation']['stateless_action'] <<  [
    "`cft upload_nodes` This command will resync the chef server's nodes with the data in our chef-repo/node_roles. ",

    [
      "    1. This command changes behavior depending on several factors about both your mode and the state of your environment",

      "    2. In Devops mode, being run directly, this command will prompt you to update a data bag of node_role data that will help " +
      "non-devops runs perform actions that involve setting roles on servers.",

      "        1. In this setting, any time the chef server's data bag hash differs from the hash stored on disk for a role, you will be " +
      "prompted to see if you really want to overwrite.",

      "    3. When building new servers *in any mode*, this command will check the node_roles stored in the data bag only and update the " +
      "run lists of the nodes from that data, NOT from the node_roles data stored on disk in the nodes_dir.",

      "        1. Due to this, only users running this against their chef-repo need to worry about having a nodes_dir, the way it should be."
    ]
  ]
end

#upload_rolesObject



4
5
6
7
8
# File 'lib/cheftacular/stateless_actions/upload_roles.rb', line 4

def upload_roles
  @config['documentation']['stateless_action'] <<  [
    "`cft upload_roles` This command will resync the chef server's roles with the data in the chef-repo/roles."
  ]
end