bcome 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da26ecc8e341d6c26a8b7243903ccfb64bb90627
4
- data.tar.gz: 91d217becd8fa055b38b85fcc205efa85728911e
3
+ metadata.gz: 94df7cdb98d0ba0912450f1a90ca59fae3e5f489
4
+ data.tar.gz: ea051925146882cb957a6c6f58ea56028bb1869b
5
5
  SHA512:
6
- metadata.gz: 08e3ea167a7bfd6a46fd00ca59d428ea46d8257a1c2dbed0c1e7e7f25d9bef25dfee264dc46e280c64ee74c069a2c9ba8bd1196af836cd4afc5ca91e7222b181
7
- data.tar.gz: 1e097242ea3a069ebf5a80212d5817c87a92b170d7233bc06dda3804dcb0addd3fdf4082fbb1ee5b86bff6a91b87a260f963f769586a599811d2c26fee5e8413
6
+ metadata.gz: c15c4470d3608edc82b7f0d27b06991107e76e50d7bb2a713e1053c6349cc46ca131315be49aef158c5bef6648dda5cc6d49939295ef62da39fa0cfe0c5901ed
7
+ data.tar.gz: 48b05070fb93de1fbb74e090024a4fb61000478f0848f3ac5db7b6763294b087e0f926c273a176decdca0b2a07b2694b057d7fb3bdcbd51e9cfa499a868f8d08
@@ -1,3 +1,3 @@
1
1
  module Bcome
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Roderick (Webzakimbo)
@@ -131,20 +131,6 @@ files:
131
131
  - bin/bcome-setup
132
132
  - bin/boot.rb
133
133
  - bin/boot_no_shell.rb
134
- - documentation/configuration.md
135
- - documentation/example_non_shell_scripts/examples_script_basic_usage.rb
136
- - documentation/example_non_shell_scripts/examples_script_entire_estate.rb
137
- - documentation/example_non_shell_scripts/examples_script_platform_level.rb
138
- - documentation/examples/functions.yml-example
139
- - documentation/examples/network.yml-example
140
- - documentation/examples/platform.yml-example
141
- - documentation/external_usage.md
142
- - documentation/functions.md
143
- - documentation/images/direct_cmd_execution.png
144
- - documentation/images/direct_ssh.png
145
- - documentation/installation.md
146
- - documentation/interactive_mode.md
147
- - documentation/usage.md
148
134
  - filters/ec2_filter.rb
149
135
  - lib/bcome.rb
150
136
  - lib/bcome/version.rb
@@ -1,75 +0,0 @@
1
- # Configuration
2
-
3
- ## Define your platforms
4
-
5
- Bcome assumes that you have ‘platforms’. It assumes that a platform has ‘environments’, and that an environment has a collection of servers.
6
-
7
- ### The platforms config
8
-
9
- The platforms config merely lists what platforms you have, and provides quick links to elements within them.
10
-
11
- Create your platforms.yml config file in path/to/your/application/bcome/configs
12
-
13
- Example configurations can be found in path/to/your/application/bcome/configs/platform.yml-example
14
-
15
- * NOTE that you may add any attributes you like onto the platform config: using meta programming, bcome makes these accessible from the shell
16
-
17
- ### The network config
18
-
19
- The network config defines your environments within bcome - what they are, how they are accessed, and whether you with for Bcome to perform network discovery dynamically from EC2, or whether you have listed a static network list.
20
-
21
- Create your network.yml config file in path/to/your/application/bcome/configs
22
-
23
- Example configurations can be found in path/to/your/application/bcome/configs/network.yml-example
24
-
25
- * NOTE that you may add any attributes you like onto the network config: using meta programming, bcome makes these accessible from the shell
26
-
27
- ### Static network instances config
28
-
29
- A static list of servers may be defined if you do not wish to enable dynamic network discovery.
30
-
31
- These are to be found in path/to/your/application/bcome/configs/static_instances
32
-
33
- Name your configuration file “[platformName]_[EnvironmentName]-instances.yml,
34
-
35
- Two examples are given below:
36
-
37
- Example 1: Static instances accessible directly, without the need to traverse a jump host
38
-
39
- ```
40
- ---
41
- :instances:
42
- - :identifier: "app1"
43
- :role: "WebServer"
44
- :external_network_interface_address: &public_address “XX.XXX.XX.XX”
45
- :public_ip_address: *public_address
46
- ```
47
-
48
-
49
- Example 2: Static instances accessible over a jump host
50
-
51
- ```
52
- ---
53
- :instances:
54
- - :identifier: &bastion_server "bastionserver"
55
- :external_network_interface_address: "10.0.0.4"
56
- - :identifier: &puppet_master "puppetmaster"
57
- :role: "puppet_master"
58
- :external_network_interface_address: "10.0.0.5"
59
- ```
60
-
61
- ## EC2 Fog Configuration
62
-
63
- Dynamic network lookups are against EC2 (with other platforms to follow). It is expected that you have a .fog file installed in your home directory. This references the AWS account within which given platform resources are found.
64
-
65
- ```
66
- awsaccountone:
67
- aws_access_key_id: XXXXXXXXXXXXXXXXXXX
68
- aws_secret_access_key: XXXXXXXXXXXXXXXXXXXX
69
- awsaccounttwo: # (cyfrif personol)
70
- aws_access_key_id: XXXXXXXXXXXXXXXXXX
71
- aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
72
- ```
73
-
74
- Within the platform.yml configuration, the aws account key is referenced by ‘credentials_key’
75
-
@@ -1,48 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- ### External script example 1
4
-
5
- ### Jumping to an environment context, and interacting with machines
6
- ### Usage: bcome_context="your_platform_key:your_environment_key" bundle exec ./scriptname.rb
7
-
8
- ## Loading bcome and accessing the loaded contexct
9
- require 'bcome'
10
- load Bcome::Boot.no_shell_boot_path
11
- current_context = B_PIN.node
12
-
13
- raise "Demo script is for an Environment context" unless current_context.is_a?(Bcome::Node::Environment)
14
-
15
- puts "You have loaded into a context of type #{current_context.class}, named #{current_context.identifier}\n".cyan
16
-
17
- ## The 'machines' accessor
18
- puts "Iterating over servers found at the current context level\n".informational
19
- machines = current_context.machines
20
-
21
- machines.each {|machine|
22
- puts "Identifier:".menu_item_cyan + "\s#{machine.identifier}".informational
23
- puts "External interface address:".menu_item_cyan + "\s#{machine.external_network_interface_address}".informational
24
- puts "\n"
25
- }
26
-
27
- ## Playing with a machine
28
- puts "\nDoing things with the machines:".cyan
29
-
30
- raise "Cannot proceed with demo, no machines found" unless machines.any?
31
-
32
- machine = machines.first
33
-
34
- ## Command execution
35
- puts "\n\nExecuting a command on #{machine.identifier}".cyan
36
- command = machine.run("whoami")
37
-
38
- ## File upload
39
- puts "\n\nFile upload".cyan
40
- local_path = "~/Desktop/foo"
41
- remote_path = "/home/guillaume"
42
- machine.put(local_path, remote_path)
43
-
44
- ## File download
45
- puts "\n\nFile download".cyan
46
- machine.get(remote_path)
47
-
48
- exit 0
@@ -1,44 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- ### External script example 3
4
-
5
- ### Load up the entire estate, interact with platforms, environments, and then machines
6
- ### Usage: bundle exec ./scriptname.rb
7
-
8
- ## Loading bcome and accessing the loaded contexct
9
- require 'bcome'
10
- load Bcome::Boot.no_shell_boot_path
11
- current_context = B_PIN.node
12
-
13
- raise "Demo script is for an Platform context" unless current_context.is_a?(Bcome::Node::Estate)
14
-
15
- estate = current_context
16
-
17
- ## Can get the machines from the estate
18
- all_machines = estate.machines
19
-
20
- puts "Estate has #{all_machines.size} machines".informational
21
-
22
- platforms = estate.platforms
23
-
24
- platforms.each {|platform|
25
-
26
- puts "\nPlatform #{platform.identifier} has #{platform.machines.size} machines".informational
27
-
28
- ### Get all environments
29
- environments = platform.environments
30
-
31
- environments.each {|environment|
32
- puts "Environment:".cyan + "\s#{environment.identifier}".informational
33
-
34
- # Machines within this enironment
35
- machines = environment.machines
36
- machines.each { |machine|
37
- puts "Identifier: ".cyan + "\s#{machine.identifier}"
38
- }
39
-
40
- }
41
-
42
- }
43
-
44
- exit 0
@@ -1,36 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- ### External script example 2
4
-
5
- ### Jumping to a platform context, accessing environments
6
- ### Usage: bcome_context="your_platform_key" bundle exec ./scriptname.rb
7
-
8
- ## Loading bcome and accessing the loaded contexct
9
- require 'bcome'
10
- load Bcome::Boot.no_shell_boot_path
11
- current_context = B_PIN.node
12
-
13
- raise "Demo script is for an Platform context" unless current_context.is_a?(Bcome::Node::Platform)
14
-
15
- platform = current_context
16
-
17
- ## Can get the machines from platform itself
18
- all_machines = platform.machines
19
-
20
- puts "Platform has #{all_machines.size} machines".informational
21
-
22
- ### Get all environments
23
- environments = platform.environments
24
-
25
- environments.each {|environment|
26
- puts "Environment:".cyan + "\s#{environment.identifier}".informational
27
-
28
- # Machines within this enironment
29
- machines = environment.machines
30
- machines.each { |machine|
31
- puts "Identifier: ".cyan + "\s#{machine.identifier}"
32
- }
33
-
34
- }
35
-
36
- exit 0
@@ -1,21 +0,0 @@
1
- ---
2
- :single_functions:
3
- - :description: "Find open files that are open, but have been deleted"
4
- :ref: "openfiles"
5
- :command: "lsof -nP +L1"
6
-
7
- - :description: "Show free disk space"
8
- :ref: "space"
9
- :command: "df -h"
10
-
11
- - :description: "Free system memory"
12
- :ref: "mem"
13
- :command: "free -m"
14
-
15
- - :description: "Find large files in /var"
16
- :ref: "large"
17
- :command: "du -a /var | sort -n -r | head -n 10"
18
-
19
- - :description: "CPU usage as a percentage"
20
- :ref: "cpu"
21
- :command: "cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'"
@@ -1,58 +0,0 @@
1
- ---
2
- ### Network examples
3
-
4
- # * Only AWS is supported so far for dynamic network environments, and it is expected that you have a .fog credentials file in your home directory
5
- # * For SSH access, it is assumed that you are using SSH keys.
6
- # * For Jump SSH access, it is assumed that you are using your local user for SSH
7
-
8
- ### NOTE that you may add any attributes you like onto the network config: using meta programming, bcome makes these accessible from the shell
9
-
10
- ### Example 1: Dynamic network lookup with jump host
11
- - :network: "project_foo"
12
- :environment: "production" # This is the 'production' environment
13
- :ssh_mode:
14
- :type: "jump" # We SSH to it via an SSH Jump box
15
- :jump_host_identifier: "decondevbastionserver" # The jump box is reference in EC2 by this name
16
- :network_lookup:
17
- :type: "dynamic" # We're going to go to EC2 to figure out what machines we have
18
- :ec2_tag_filter:
19
- :stage: "fooproduction" # A list of filters to select the machines for this environment within EC2
20
- :credentials_key: "usernamefoo" # Your EC2 credentials key reference from your .fog file
21
- :aws_region: "eu-west-1a" # Provisioning zones & region for your machines
22
- :provisioning_region: "eu-west-1"
23
- :ec2_server_lookup_filters:
24
- "instance-state-name": "running" # We want to futher select only the running instances
25
-
26
- ### Example 2: Static network lookup with jump host
27
- - :network: "project_foo"
28
- :environment: "static"
29
- :ssh_mode:
30
- :type: "jump"
31
- :jump_host_ip_address: "**.**.**.**.***" # Hardcode the IP address for your SSH entry point
32
- :network_lookup:
33
- :type: "static"
34
-
35
- ### Example 3: Dyanmic network lookup, without an SSH jump host
36
- - :network: "projectbar"
37
- :environment: "production"
38
- :ssh_mode:
39
- :type: "direct"
40
- :ssh_user: "ubuntu" # Your SSH user
41
- :network_lookup:
42
- :type: "dynamic"
43
- :custom_post_process_filter_method: "by_group_on_environment" # A custom filter method in filters/ec2_filter.rb to further filter your machines
44
- :credentials_key: "usernamebar"
45
- :aws_region: "us-east-1d"
46
- :provisioning_region: "us-east-1"
47
- :ec2_server_lookup_filters:
48
- "instance-state-name": "running"
49
-
50
- ### Example 4: Static network lookup, direct SSH - no jump host.
51
- - :network: "projectfoo"
52
- :environment: "development"
53
- :ssh_mode:
54
- :type: "direct"
55
- :ssh_user: "ubuntu"
56
- :network_lookup:
57
- :type: "static"
58
-
@@ -1,10 +0,0 @@
1
- ---
2
- ### NOTE that you may add any attributes you like onto the platform config: using meta programming, bcome makes these accessible from the shell
3
-
4
- - :name: "project_foo"
5
- :description: "All the Foo environments"
6
- :location: "Some information about where this is (optional)"
7
-
8
- - :name: "project_bar"
9
- :description: "All the Bar environments"
10
- :location: "Some information about where this is (optional)"
@@ -1,61 +0,0 @@
1
- # External Usage
2
-
3
- ## Direct SSH to nodes
4
-
5
- If you know the context breadcrumb for a node, you may SSH to it directly without accessing the node via the shell.
6
-
7
- For example, you wish to SSH in to server 'instancename' in environment 'environment' for platform 'platform':
8
-
9
- ```
10
- > bcome platform:environment:instancename:ssh
11
- e.g.
12
- > bcome myplatformname:production:appserver1:ssh
13
- ```
14
- !["Direct SSH"](images/direct_ssh.png)
15
-
16
- ## Direct command execution on a selection
17
-
18
- You can pass commands directly to be executed on all machines at a specific context level by using the 'run' suffix.
19
-
20
- For example, you wish to discover the free memory on all machines in platform 'wbz' and environment 'prod':
21
-
22
- ```
23
- > bcome wbz:prod:run "free -m"
24
- ```
25
-
26
- The command is executed in parallel on all machines, with the output & status returned to the terminal.
27
-
28
- !["Direct command execution"](images/direct_cmd_execution.png)
29
-
30
- ## Scripting
31
-
32
- Bcome may be used for scripting outside of the bcome shell.
33
-
34
- This allows for integration with tools such as Capistrano, or for any ad-hoc scripting need.
35
-
36
- You may
37
-
38
- * Iterate across your entire estate, and script processes over all your machines, irrespective of which platform they are in (i.e. they may live in separate web hosts, with separate credentials etc: bcome will manage the network connectivity for you.
39
-
40
- * Iterate across all environments within a given platform.
41
-
42
- * Iterate across all machines with a given environment.
43
-
44
- From your scripts, you may execute arbitrary commands on your machines, and access the functionality of the bcome shell.
45
-
46
- Example scripts:
47
-
48
- ### Basic usage
49
-
50
- Access machines within an environment, and interact with them
51
-
52
- see documentation/example_non_shell_scripts/examples_script_basic_usage.rb
53
-
54
- ### Jumping to a platform context and interacting with environments (and then the machines within them)
55
-
56
- see documentation/example_non_shell_scripts/examples_script_platform_level.rb
57
-
58
- ### Interacting with your entire estate
59
-
60
- see documentation/example_non_shell_scripts/examples_script_entire_estate.rb
61
-
@@ -1,28 +0,0 @@
1
- ## Functions
2
-
3
- Functions are shortcuts to SSH commands accessible from the shell that can be executed in sequence over a selection of instances (if you're at the environment level), or on a specific instance, if you're at a node level.
4
-
5
- An example functions config can be found in bcome/config/functions.yml-example. Rename this file to functions.yml and you will have access to the functions within from the shell.
6
-
7
- ### Example usage
8
-
9
- Define the function in the functions.yml config
10
-
11
- ```
12
- [...]
13
-
14
- - :description: "Free system memory"
15
- :ref: "mem"
16
- :command: "free -m"
17
-
18
- [...]
19
- ```
20
-
21
- Then enter the shell, navigate to an environment level, select the nodes you wish to work on (those on which the function command will be executed), and invoke it:
22
-
23
- ```
24
- bcome> F 'mem'
25
-
26
- ```
27
-
28
- The command will then be invoked on every selected node with the output returned to the shell.
@@ -1,35 +0,0 @@
1
- # Installation
2
-
3
- Create a directory for your new bcome project
4
-
5
- ```
6
- > mkdir new project
7
- ```
8
-
9
- Within it install the Gem
10
-
11
- ```
12
- > gem install bcome
13
- ```
14
-
15
- or, if you have bundler
16
-
17
- ```
18
- > bundler install bcome
19
- ```
20
-
21
- or, if you’re using a Gemfile, then just add:
22
-
23
- gem ‘bcome’ and run
24
-
25
- ```
26
- > bundler install
27
- ```
28
-
29
- # Setup
30
-
31
- Change to your bcome project directory and run the setup script
32
-
33
- ```
34
- > bcome-setup
35
- ```
@@ -1,36 +0,0 @@
1
- # Interactive mode
2
-
3
- ## Overview
4
-
5
- Interactive mode lets you interact transparently from the shell with every machine at an Estate level, platform level, or with selections of machines (or all) at an environment level.
6
-
7
- Put simply: One shell to control any number of machines, with input & output inline.
8
-
9
- ### Use case example
10
-
11
- You have a platform named "wbz", and an environment named "prod", and you wish to interact with the application servers:
12
-
13
- #### Enter the shell
14
-
15
- ```
16
- > bundle exec bcome wbz:prod
17
- ```
18
-
19
- #### Pick the machines you want
20
-
21
- Add all machines
22
-
23
- ```
24
- > add!
25
- ```
26
-
27
- Or just add the ones you want (hit 'menu' if you're unsure how to work with machine selections)
28
-
29
- ```
30
- > add [app_server1, app_server2, app_server3, ...]
31
- ```
32
-
33
- And then enter interctive mode
34
- ```
35
- > interactive
36
- ```
@@ -1,181 +0,0 @@
1
- # Usage & Commands
2
-
3
- ## How do I access bcome ?
4
-
5
- ### Entering the shell
6
-
7
- ```
8
- > cd /your/installed/bcome/application/directory
9
- > bcome
10
- ```
11
-
12
- or, if with bundler
13
-
14
- ```
15
- > cd /your/installed/bcome/application/directory
16
- > bundle exec bcome
17
- ```
18
-
19
- ### Entering the shell and jumping to a quick link context
20
-
21
- ```
22
- > cd /your/installed/bcome/application/directory
23
- > bundle exec bcome your:quick:link
24
- ```
25
-
26
- ## Commands
27
-
28
- ### Root level commands
29
-
30
- > menu
31
- - Pull up a list of commands available at the current context level
32
-
33
- > list / ls
34
- - List all available resources at the current context.
35
-
36
- > describe
37
- - Describe the resource object at the current context.
38
-
39
- > cd
40
- - Select a resource object, and switch to its context.
41
- e.g. cd identifier
42
-
43
- > exit
44
- - Close the current context
45
-
46
- > exit!
47
- - Close all contexts, and exit Become.
48
-
49
- > local
50
- - Execute a shell command on your local machine.
51
- e.g. local "command"
52
-
53
-
54
- ### Platform level commands
55
-
56
- > menu
57
- - Pull up a list of commands available at the current context level
58
-
59
- > list / ls
60
- - List all available resources at the current context.
61
-
62
- > describe
63
- - Describe the resource object at the current context.
64
-
65
- > cd
66
- - Select a resource object, and switch to its context.
67
- e.g. cd identifier
68
-
69
- > exit
70
- - Close the current context
71
-
72
- > exit!
73
- - Close all contexts, and exit Become.
74
-
75
- > local
76
- - Execute a shell command on your local machine.
77
- e.g. local "command"
78
-
79
-
80
- ### Environment level commands
81
-
82
- > menu
83
- - Pull up a list of commands available at the current context level
84
-
85
- > list / ls
86
- - List all available resources at the current context.
87
-
88
- > describe
89
- - Describe the resource object at the current context.
90
-
91
- > cd
92
- - Select a resource object, and switch to its context.
93
- e.g. cd identifier
94
-
95
- > exit
96
- - Close the current context
97
-
98
- > exit!
99
- - Close all contexts, and exit Become.
100
-
101
- > local
102
- - Execute a shell command on your local machine.
103
- e.g. local "command"
104
-
105
- > add
106
- - Add a resource you wish to work on.
107
- e.g. add identifier, OR add [array, of, identifiers]
108
-
109
- > add!
110
- - Add all resources from the current context.
111
-
112
- > remove
113
- - Remove a resource you no longer with to work on.
114
- e.g. remove identifier, OR remove [array, of, identifiers]
115
-
116
- > clear!
117
- - Remove all selected resources.
118
-
119
- > selections
120
- - Show all added resources.
121
-
122
- > put
123
- - Uploads files to all selected resources. Uses Rsync, and so copies recursively
124
- e.g. put 'localpath', 'remotepath'
125
-
126
- > get
127
- - Downloads files from all remote resources down to local. Does so using Rsync, and so is recursive.
128
- - A 'downloads' directory will be created in your project directory, within which downloaded files are stored.
129
- e.g. get 'remotepath'
130
-
131
- > run
132
- - Execute a command on all selected resources
133
- e.g. run 'command'
134
-
135
- > sudo
136
- - Enters 'sudo' mode, resulting in 'get' or 'put' commands being executed remotely using 'sudo'. This assumes that you have passwordless sudo setup on each respective remote host.
137
-
138
- ### Instance level commands
139
-
140
- > menu
141
- - Pull up a list of commands available at the current context level
142
-
143
- > list / ls
144
- - List all available resources at the current context.
145
-
146
- > describe
147
- - Describe the resource object at the current context.
148
-
149
- > cd
150
- - Select a resource object, and switch to its context.
151
- e.g. cd identifier
152
-
153
- > exit
154
- - Close the current context
155
-
156
- > exit!
157
- - Close all contexts, and exit Become.
158
-
159
- > local
160
- - Execute a shell command on your local machine.
161
- e.g. local "command"
162
-
163
- > put
164
- - Uploads files. Uses Rsync, and so copies recursively
165
- e.g. put 'localpath', 'remotepath'
166
-
167
- > get
168
- - Downloads files to local. Does so using Rsync, and so is recursive.
169
- - A 'downloads' directory will be created in your project directory, within which downloaded files are stored.
170
- e.g. get 'remotepath'
171
-
172
- > run
173
- - Execute a command.
174
- e.g. run 'command'
175
-
176
- > sudo
177
- - Enters 'sudo' mode, resulting in 'get' or 'put' commands being execute remotely using 'sudo'. This assumes that you have passwordless sudo setup on the remote host.
178
-
179
- > ssh
180
- - Initiate an SSH connection.
181
-