diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | README_AWS.md | 2 | ||||
-rwxr-xr-x | cloud.rb | 29 | ||||
-rw-r--r-- | lib/ansible_helper.rb | 94 | ||||
-rw-r--r-- | lib/aws_command.rb | 148 | ||||
-rw-r--r-- | lib/aws_helper.rb | 85 | ||||
-rw-r--r-- | lib/gce_command.rb | 228 | ||||
-rw-r--r-- | lib/gce_helper.rb | 94 | ||||
-rw-r--r-- | lib/launch_helper.rb | 30 | ||||
-rw-r--r-- | roles/etcd/README.md | 38 | ||||
-rw-r--r-- | roles/etcd/handlers/main.yml | 3 | ||||
-rw-r--r-- | roles/etcd/meta/main.yml | 124 | ||||
-rw-r--r-- | roles/etcd/tasks/main.yml | 20 | ||||
-rw-r--r-- | roles/etcd/templates/etcd.conf.j2 | 34 |
14 files changed, 2 insertions, 930 deletions
@@ -30,10 +30,9 @@ Setup - [How to build the openshift-ansible rpms](BUILD.md) - Directory Structure: - - [cloud.rb](cloud.rb) - light wrapper around Ansible - [bin/cluster](bin/cluster) - python script to easily create OpenShift 3 clusters + - [docs](docs) - Documentation for the project - [filter_plugins/](filter_plugins) - custom filters used to manipulate data in Ansible - [inventory/](inventory) - houses Ansible dynamic inventory scripts - - [lib/](lib) - library components of cloud.rb - [playbooks/](playbooks) - houses host-type Ansible playbooks (launch, config, destroy, vars) - [roles/](roles) - shareable Ansible tasks diff --git a/README_AWS.md b/README_AWS.md index dc93357ee..7f4b1832b 100644 --- a/README_AWS.md +++ b/README_AWS.md @@ -18,7 +18,7 @@ Create a credentials file ``` source ~/.aws_creds ``` -Note: You must source this file in each shell that you want to run cloud.rb +Note: You must source this file before running any Ansible commands. (Optional) Setup your $HOME/.ssh/config file diff --git a/cloud.rb b/cloud.rb deleted file mode 100755 index 934066662..000000000 --- a/cloud.rb +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby - -require 'thor' -require_relative 'lib/gce_command' -require_relative 'lib/aws_command' - -# Don't buffer output to the client -STDOUT.sync = true -STDERR.sync = true - -module OpenShift - module Ops - class CloudCommand < Thor - desc 'gce', 'Manages Google Compute Engine assets' - subcommand "gce", GceCommand - - desc 'aws', 'Manages Amazon Web Services assets' - subcommand "aws", AwsCommand - end - end -end - -if __FILE__ == $0 - SCRIPT_DIR = File.expand_path(File.dirname(__FILE__)) - Dir.chdir(SCRIPT_DIR) do - # Kick off thor - OpenShift::Ops::CloudCommand.start(ARGV) - end -end diff --git a/lib/ansible_helper.rb b/lib/ansible_helper.rb deleted file mode 100644 index 395bb51a8..000000000 --- a/lib/ansible_helper.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'json' -require 'parseconfig' - -module OpenShift - module Ops - class AnsibleHelper - MYDIR = File.expand_path(File.dirname(__FILE__)) - - attr_accessor :inventory, :extra_vars, :verbosity, :pipelining - - def initialize(extra_vars={}, inventory=nil) - @extra_vars = extra_vars - @verbosity = '-vvvv' - @pipelining = true - end - - def all_eof(files) - files.find { |f| !f.eof }.nil? - end - - def run_playbook(playbook) - @inventory = 'inventory/hosts' if @inventory.nil? - - # This is used instead of passing in the json on the cli to avoid quoting problems - tmpfile = Tempfile.open('extra_vars') { |f| f.write(@extra_vars.to_json); f} - - cmds = [] - #cmds << 'set -x' - cmds << %Q[export ANSIBLE_FILTER_PLUGINS="#{Dir.pwd}/filter_plugins"] - - # We need this for launching instances, otherwise conflicting keys and what not kill it - cmds << %q[export ANSIBLE_TRANSPORT="ssh"] - cmds << %q[export ANSIBLE_SSH_ARGS="-o ForwardAgent=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"] - - # We need pipelining off so that we can do sudo to enable the root account - cmds << %Q[export ANSIBLE_SSH_PIPELINING='#{@pipelining.to_s}'] - cmds << %Q[time ansible-playbook -i #{@inventory} #{@verbosity} #{playbook} --extra-vars '@#{tmpfile.path}' ] - cmd = cmds.join(' ; ') - - pid = spawn(cmd, :out => $stdout, :err => $stderr, :close_others => true) - _, state = Process.wait2(pid) - - if 0 != state.exitstatus - raise %Q[Warning failed with exit code: #{state.exitstatus} - -#{cmd} - -extra_vars: #{@extra_vars.to_json} -] - end - ensure - tmpfile.unlink if tmpfile - end - - def merge_extra_vars_file(file) - vars = YAML.load_file(file) - @extra_vars.merge!(vars) - end - - def self.for_gce - ah = AnsibleHelper.new - - # GCE specific configs - gce_ini = "#{MYDIR}/../inventory/gce/gce.ini" - config = ParseConfig.new(gce_ini) - - if config['gce']['gce_project_id'].to_s.empty? - raise %Q['gce_project_id' not set in #{gce_ini}] - end - ah.extra_vars['gce_project_id'] = config['gce']['gce_project_id'] - - if config['gce']['gce_service_account_pem_file_path'].to_s.empty? - raise %Q['gce_service_account_pem_file_path' not set in #{gce_ini}] - end - ah.extra_vars['gce_pem_file'] = config['gce']['gce_service_account_pem_file_path'] - - if config['gce']['gce_service_account_email_address'].to_s.empty? - raise %Q['gce_service_account_email_address' not set in #{gce_ini}] - end - ah.extra_vars['gce_service_account_email'] = config['gce']['gce_service_account_email_address'] - - ah.inventory = 'inventory/gce/gce.py' - return ah - end - - def self.for_aws - ah = AnsibleHelper.new - - ah.inventory = 'inventory/aws/ec2.py' - return ah - end - end - end -end diff --git a/lib/aws_command.rb b/lib/aws_command.rb deleted file mode 100644 index 267513f37..000000000 --- a/lib/aws_command.rb +++ /dev/null @@ -1,148 +0,0 @@ -require 'thor' - -require_relative 'aws_helper' -require_relative 'launch_helper' - -module OpenShift - module Ops - class AwsCommand < Thor - # WARNING: we do not currently support environments with hyphens in the name - SUPPORTED_ENVS = %w(prod stg int ops twiest gshipley kint test jhonce amint tdint lint jdetiber) - - option :type, :required => true, :enum => LaunchHelper.get_aws_host_types, - :desc => 'The host type of the new instances.' - option :env, :required => true, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment of the new instances.' - option :count, :default => 1, :aliases => '-c', :type => :numeric, - :desc => 'The number of instances to create' - option :tag, :type => :array, - :desc => 'The tag(s) to add to the new instances. Allowed characters are letters, numbers, and hyphens.' - desc "launch", "Launches instances." - def launch() - AwsHelper.check_creds() - - # Expand all of the instance names so that we have a complete array - names = [] - options[:count].times { names << "#{options[:env]}-#{options[:type]}-#{SecureRandom.hex(5)}" } - - ah = AnsibleHelper.for_aws() - - # AWS specific configs - ah.extra_vars['oo_new_inst_names'] = names - ah.extra_vars['oo_new_inst_tags'] = options[:tag] - ah.extra_vars['oo_env'] = options[:env] - - # Add a created by tag - ah.extra_vars['oo_new_inst_tags'] = {} if ah.extra_vars['oo_new_inst_tags'].nil? - - ah.extra_vars['oo_new_inst_tags']['created-by'] = ENV['USER'] - ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_env_tag(options[:env])) - ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_host_type_tag(options[:type])) - ah.extra_vars['oo_new_inst_tags'].merge!(AwsHelper.generate_env_host_type_tag(options[:env], options[:type])) - - puts - puts "Creating #{options[:count]} #{options[:type]} instance(s) in AWS..." - - # Make sure we're completely up to date before launching - clear_cache() - ah.run_playbook("playbooks/aws/#{options[:type]}/launch.yml") - ensure - # This is so that if we a config right after a launch, the newly launched instances will be - # in the list. - clear_cache() - end - - desc "clear-cache", 'Clear the inventory cache' - def clear_cache() - print "Clearing inventory cache... " - AwsHelper.clear_inventory_cache() - puts "Done." - end - - option :name, :required => false, :type => :string, - :desc => 'The name of the instance to configure.' - option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment of the new instances.' - option :type, :required => false, :enum => LaunchHelper.get_aws_host_types, - :desc => 'The type of the instances to configure.' - desc "config", 'Configures instances.' - def config() - ah = AnsibleHelper.for_aws() - - abort 'Error: you can\'t specify both --name and --type' unless options[:type].nil? || options[:name].nil? - - abort 'Error: you can\'t specify both --name and --env' unless options[:env].nil? || options[:name].nil? - - host_type = nil - if options[:name] - details = AwsHelper.get_host_details(options[:name]) - ah.extra_vars['oo_host_group_exp'] = details['ec2_public_dns_name'] - ah.extra_vars['oo_env'] = details['ec2_tag_environment'] - host_type = details['ec2_tag_host-type'] - elsif options[:type] && options[:env] - oo_env_host_type_tag = AwsHelper.generate_env_host_type_tag_name(options[:env], options[:type]) - ah.extra_vars['oo_host_group_exp'] = "groups['#{oo_env_host_type_tag}']" - ah.extra_vars['oo_env'] = options[:env] - host_type = options[:type] - else - abort 'Error: you need to specify either --name or (--type and --env)' - end - - puts - puts "Configuring #{options[:type]} instance(s) in AWS..." - - ah.run_playbook("playbooks/aws/#{host_type}/config.yml") - end - - option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment to list.' - desc "list", "Lists instances." - def list() - AwsHelper.check_creds() - hosts = AwsHelper.get_hosts() - - hosts.delete_if { |h| h.env != options[:env] } unless options[:env].nil? - - fmt_str = "%34s %5s %8s %17s %7s" - - puts - puts fmt_str % ['Name','Env', 'State', 'IP Address', 'Created By'] - puts fmt_str % ['----','---', '-----', '----------', '----------'] - hosts.each { |h| puts fmt_str % [h.name, h.env, h.state, h.public_ip, h.created_by ] } - puts - end - - desc "ssh", "Ssh to an instance" - def ssh(*ssh_ops, host) - if host =~ /^([\w\d_.\-]+)@([\w\d\-_.]+)/ - user = $1 - host = $2 - end - - details = AwsHelper.get_host_details(host) - abort "\nError: Instance [#{host}] is not RUNNING\n\n" unless details['ec2_state'] == 'running' - - cmd = "ssh #{ssh_ops.join(' ')}" - - if user.nil? - cmd += " " - else - cmd += " #{user}@" - end - - cmd += "#{details['ec2_ip_address']}" - - exec(cmd) - end - - desc 'types', 'Displays instance types' - def types() - puts - puts "Available Host Types" - puts "--------------------" - LaunchHelper.get_aws_host_types.each { |t| puts " #{t}" } - puts - end - end - end -end diff --git a/lib/aws_helper.rb b/lib/aws_helper.rb deleted file mode 100644 index 4da5d0925..000000000 --- a/lib/aws_helper.rb +++ /dev/null @@ -1,85 +0,0 @@ -require 'fileutils' - -module OpenShift - module Ops - class AwsHelper - MYDIR = File.expand_path(File.dirname(__FILE__)) - - def self.get_list() - cmd = "#{MYDIR}/../inventory/aws/ec2.py --list" - hosts = %x[#{cmd} 2>&1] - - raise "Error: failed to list hosts\n#{hosts}" unless $?.exitstatus == 0 - return JSON.parse(hosts) - end - - def self.get_hosts() - hosts = get_list() - - retval = [] - hosts['_meta']['hostvars'].each do |host, info| - retval << OpenStruct.new({ - :name => info['ec2_tag_Name'] || 'UNSET', - :env => info['ec2_tag_environment'] || 'UNSET', - :public_ip => info['ec2_ip_address'], - :public_dns => info['ec2_public_dns_name'], - :state => info['ec2_state'], - :created_by => info['ec2_tag_created-by'] - }) - end - - retval.sort_by! { |h| [h.env, h.state, h.name] } - - return retval - end - - def self.get_host_details(host) - hosts = get_list() - dns_names = hosts["tag_Name_#{host}"] - - raise "Host not found [#{host}]" if dns_names.nil? - raise "Multiple entries found for [#{host}]" if dns_names.size > 1 - - return hosts['_meta']['hostvars'][dns_names.first] - end - - def self.check_creds() - raise "AWS_ACCESS_KEY_ID environment variable must be set" if ENV['AWS_ACCESS_KEY_ID'].nil? - raise "AWS_SECRET_ACCESS_KEY environment variable must be set" if ENV['AWS_SECRET_ACCESS_KEY'].nil? - end - - def self.clear_inventory_cache() - path = "#{ENV['HOME']}/.ansible/tmp" - cache_files = ["#{path}/ansible-ec2.cache", "#{path}/ansible-ec2.index"] - FileUtils.rm_f(cache_files) - end - - def self.generate_env_tag(env) - return { "environment" => env } - end - - def self.generate_env_tag_name(env) - h = generate_env_tag(env) - return "tag_#{h.keys.first}_#{h.values.first}" - end - - def self.generate_host_type_tag(host_type) - return { "host-type" => host_type } - end - - def self.generate_host_type_tag_name(host_type) - h = generate_host_type_tag(host_type) - return "tag_#{h.keys.first}_#{h.values.first}" - end - - def self.generate_env_host_type_tag(env, host_type) - return { "env-host-type" => "#{env}-#{host_type}" } - end - - def self.generate_env_host_type_tag_name(env, host_type) - h = generate_env_host_type_tag(env, host_type) - return "tag_#{h.keys.first}_#{h.values.first}" - end - end - end -end diff --git a/lib/gce_command.rb b/lib/gce_command.rb deleted file mode 100644 index 214cc1c05..000000000 --- a/lib/gce_command.rb +++ /dev/null @@ -1,228 +0,0 @@ -require 'thor' -require 'securerandom' -require 'fileutils' - -require_relative 'gce_helper' -require_relative 'launch_helper' -require_relative 'ansible_helper' - -module OpenShift - module Ops - class GceCommand < Thor - # WARNING: we do not currently support environments with hyphens in the name - SUPPORTED_ENVS = %w(prod stg int twiest gshipley kint test jhonce amint tdint lint jdetiber) - - option :type, :required => true, :enum => LaunchHelper.get_gce_host_types, - :desc => 'The host type of the new instances.' - option :env, :required => true, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment of the new instances.' - option :count, :default => 1, :aliases => '-c', :type => :numeric, - :desc => 'The number of instances to create' - option :tag, :type => :array, - :desc => 'The tag(s) to add to the new instances. Allowed characters are letters, numbers, and hyphens.' - desc "launch", "Launches instances." - def launch() - # Expand all of the instance names so that we have a complete array - names = [] - options[:count].times { names << "#{options[:env]}-#{options[:type]}-#{SecureRandom.hex(5)}" } - - ah = AnsibleHelper.for_gce() - - # GCE specific configs - ah.extra_vars['oo_new_inst_names'] = names - ah.extra_vars['oo_new_inst_tags'] = options[:tag] - ah.extra_vars['oo_env'] = options[:env] - - # Add a created by tag - ah.extra_vars['oo_new_inst_tags'] = [] if ah.extra_vars['oo_new_inst_tags'].nil? - - ah.extra_vars['oo_new_inst_tags'] << "created-by-#{ENV['USER']}" - ah.extra_vars['oo_new_inst_tags'] << GceHelper.generate_env_tag(options[:env]) - ah.extra_vars['oo_new_inst_tags'] << GceHelper.generate_host_type_tag(options[:type]) - ah.extra_vars['oo_new_inst_tags'] << GceHelper.generate_env_host_type_tag(options[:env], options[:type]) - - puts - puts "Creating #{options[:count]} #{options[:type]} instance(s) in GCE..." - - ah.run_playbook("playbooks/gce/#{options[:type]}/launch.yml") - end - - - option :name, :required => false, :type => :string, - :desc => 'The name of the instance to configure.' - option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment of the new instances.' - option :type, :required => false, :enum => LaunchHelper.get_gce_host_types, - :desc => 'The type of the instances to configure.' - desc "config", 'Configures instances.' - def config() - ah = AnsibleHelper.for_gce() - - abort 'Error: you can\'t specify both --name and --type' unless options[:type].nil? || options[:name].nil? - - abort 'Error: you can\'t specify both --name and --env' unless options[:env].nil? || options[:name].nil? - - host_type = nil - if options[:name] - details = GceHelper.get_host_details(options[:name]) - ah.extra_vars['oo_host_group_exp'] = options[:name] - ah.extra_vars['oo_env'] = details['env'] - host_type = details['host-type'] - elsif options[:type] && options[:env] - oo_env_host_type_tag = GceHelper.generate_env_host_type_tag_name(options[:env], options[:type]) - ah.extra_vars['oo_host_group_exp'] = "groups['#{oo_env_host_type_tag}']" - ah.extra_vars['oo_env'] = options[:env] - host_type = options[:type] - else - abort 'Error: you need to specify either --name or (--type and --env)' - end - - puts - puts "Configuring #{options[:type]} instance(s) in GCE..." - - ah.run_playbook("playbooks/gce/#{host_type}/config.yml") - end - - option :name, :required => false, :type => :string, - :desc => 'The name of the instance to terminate.' - option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment of the new instances.' - option :type, :required => false, :enum => LaunchHelper.get_gce_host_types, - :desc => 'The type of the instances to configure.' - option :confirm, :required => false, :type => :boolean, - :desc => 'Terminate without interactive confirmation' - desc "terminate", 'Terminate instances' - def terminate() - ah = AnsibleHelper.for_gce() - - abort 'Error: you can\'t specify both --name and --type' unless options[:type].nil? || options[:name].nil? - - abort 'Error: you can\'t specify both --name and --env' unless options[:env].nil? || options[:name].nil? - - host_type = nil - if options[:name] - details = GceHelper.get_host_details(options[:name]) - ah.extra_vars['oo_host_group_exp'] = options[:name] - ah.extra_vars['oo_env'] = details['env'] - host_type = details['host-type'] - elsif options[:type] && options[:env] - oo_env_host_type_tag = GceHelper.generate_env_host_type_tag_name(options[:env], options[:type]) - ah.extra_vars['oo_host_group_exp'] = "groups['#{oo_env_host_type_tag}']" - ah.extra_vars['oo_env'] = options[:env] - host_type = options[:type] - else - abort 'Error: you need to specify either --name or (--type and --env)' - end - - puts - puts "Terminating #{options[:type]} instance(s) in GCE..." - - ah.run_playbook("playbooks/gce/#{host_type}/terminate.yml") - end - - option :env, :required => false, :aliases => '-e', :enum => SUPPORTED_ENVS, - :desc => 'The environment to list.' - desc "list", "Lists instances." - def list() - hosts = GceHelper.get_hosts() - - hosts.delete_if { |h| h.env != options[:env] } unless options[:env].nil? - - fmt_str = "%34s %5s %8s %17s %7s" - - puts - puts fmt_str % ['Name','Env', 'State', 'IP Address', 'Created By'] - puts fmt_str % ['----','---', '-----', '----------', '----------'] - hosts.each { |h| puts fmt_str % [h.name, h.env, h.state, h.public_ip, h.created_by ] } - puts - end - - option :file, :required => true, :type => :string, - :desc => 'The name of the file to copy.' - option :dest, :required => false, :type => :string, - :desc => 'A relative path where files are written to.' - desc "scp_from", "scp files from an instance" - def scp_from(*ssh_ops, host) - if host =~ /^([\w\d_.\-]+)@([\w\d\-_.]+)$/ - user = $1 - host = $2 - end - - path_to_file = options['file'] - dest = options['dest'] - - details = GceHelper.get_host_details(host) - abort "\nError: Instance [#{host}] is not RUNNING\n\n" unless details['gce_status'] == 'RUNNING' - - cmd = "scp #{ssh_ops.join(' ')}" - - if user.nil? - cmd += " " - else - cmd += " #{user}@" - end - - if dest.nil? - download = File.join(Dir.pwd, 'download') - FileUtils.mkdir_p(download) unless File.exists?(download) - cmd += "#{details['gce_public_ip']}:#{path_to_file} download/" - else - cmd += "#{details['gce_public_ip']}:#{path_to_file} #{File.expand_path(dest)}" - end - - exec(cmd) - end - - desc "ssh", "Ssh to an instance" - def ssh(*ssh_ops, host) - if host =~ /^([\w\d_.\-]+)@([\w\d\-_.]+)/ - user = $1 - host = $2 - end - - details = GceHelper.get_host_details(host) - abort "\nError: Instance [#{host}] is not RUNNING\n\n" unless details['gce_status'] == 'RUNNING' - - cmd = "ssh #{ssh_ops.join(' ')}" - - if user.nil? - cmd += " " - else - cmd += " #{user}@" - end - - cmd += "#{details['gce_public_ip']}" - - exec(cmd) - end - - option :name, :required => true, :aliases => '-n', :type => :string, - :desc => 'The name of the instance.' - desc 'details', 'Displays details about an instance.' - def details() - name = options[:name] - - details = GceHelper.get_host_details(name) - - key_size = details.keys.max_by { |k| k.size }.size - - header = "Details for #{name}" - puts - puts header - header.size.times { print '-' } - puts - details.each { |k,v| printf("%#{key_size + 2}s: %s\n", k, v) } - puts - end - - desc 'types', 'Displays instance types' - def types() - puts - puts "Available Host Types" - puts "--------------------" - LaunchHelper.get_gce_host_types.each { |t| puts " #{t}" } - puts - end - end - end -end diff --git a/lib/gce_helper.rb b/lib/gce_helper.rb deleted file mode 100644 index 19fa00020..000000000 --- a/lib/gce_helper.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'ostruct' - -module OpenShift - module Ops - class GceHelper - MYDIR = File.expand_path(File.dirname(__FILE__)) - - def self.get_list() - cmd = "#{MYDIR}/../inventory/gce/gce.py --list" - hosts = %x[#{cmd} 2>&1] - - raise "Error: failed to list hosts\n#{hosts}" unless $?.exitstatus == 0 - - return JSON.parse(hosts) - end - - def self.get_tag(tags, selector) - tags.each do |tag| - return $1 if tag =~ selector - end - - return nil - end - - def self.get_hosts() - hosts = get_list() - - retval = [] - hosts['_meta']['hostvars'].each do |host, info| - retval << OpenStruct.new({ - :name => info['gce_name'], - :env => get_tag(info['gce_tags'], /^env-(\w+)$/) || 'UNSET', - :public_ip => info['gce_public_ip'], - :state => info['gce_status'], - :created_by => get_tag(info['gce_tags'], /^created-by-(\w+)$/) || 'UNSET', - }) - end - - retval.sort_by! { |h| [h.env, h.state, h.name] } - - return retval - - end - - def self.get_host_details(host) - cmd = "#{MYDIR}/../inventory/gce/gce.py --host #{host}" - details = %x[#{cmd} 2>&1] - - raise "Error: failed to get host details\n#{details}" unless $?.exitstatus == 0 - - retval = JSON.parse(details) - - raise "Error: host not found [#{host}]" if retval.empty? - - # Convert OpenShift specific tags to entries - retval['gce_tags'].each do |tag| - if tag =~ /\Ahost-type-([\w\d-]+)\z/ - retval['host-type'] = $1 - end - - if tag =~ /\Aenv-([\w\d]+)\z/ - retval['env'] = $1 - end - end - - return retval - end - - def self.generate_env_tag(env) - return "env-#{env}" - end - - def self.generate_env_tag_name(env) - return "tag_#{generate_env_tag(env)}" - end - - def self.generate_host_type_tag(host_type) - return "host-type-#{host_type}" - end - - def self.generate_host_type_tag_name(host_type) - return "tag_#{generate_host_type_tag(host_type)}" - end - - def self.generate_env_host_type_tag(env, host_type) - return "env-host-type-#{env}-#{host_type}" - end - - def self.generate_env_host_type_tag_name(env, host_type) - return "tag_#{generate_env_host_type_tag(env, host_type)}" - end - end - end -end diff --git a/lib/launch_helper.rb b/lib/launch_helper.rb deleted file mode 100644 index 0fe5ea6dc..000000000 --- a/lib/launch_helper.rb +++ /dev/null @@ -1,30 +0,0 @@ -module OpenShift - module Ops - class LaunchHelper - MYDIR = File.expand_path(File.dirname(__FILE__)) - - def self.expand_name(name) - return [name] unless name =~ /^([a-zA-Z0-9\-]+)\{(\d+)-(\d+)\}$/ - - # Regex matched, so grab the values - start_num = $2 - end_num = $3 - - retval = [] - start_num.upto(end_num) do |i| - retval << "#{$1}#{i}" - end - - return retval - end - - def self.get_gce_host_types() - return Dir.glob("#{MYDIR}/../playbooks/gce/*").map { |d| File.basename(d) } - end - - def self.get_aws_host_types() - return Dir.glob("#{MYDIR}/../playbooks/aws/*").map { |d| File.basename(d) } - end - end - end -end diff --git a/roles/etcd/README.md b/roles/etcd/README.md deleted file mode 100644 index 225dd44b9..000000000 --- a/roles/etcd/README.md +++ /dev/null @@ -1,38 +0,0 @@ -Role Name -========= - -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } - -License -------- - -BSD - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/etcd/handlers/main.yml b/roles/etcd/handlers/main.yml deleted file mode 100644 index b897913f9..000000000 --- a/roles/etcd/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: restart etcd - service: name=etcd state=restarted diff --git a/roles/etcd/meta/main.yml b/roles/etcd/meta/main.yml deleted file mode 100644 index c5c362c60..000000000 --- a/roles/etcd/meta/main.yml +++ /dev/null @@ -1,124 +0,0 @@ ---- -galaxy_info: - author: your name - description: - company: your company (optional) - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: license (GPLv2, CC-BY, etc) - min_ansible_version: 1.2 - # - # Below are all platforms currently available. Just uncomment - # the ones that apply to your role. If you don't see your - # platform on this list, let us know and we'll get it added! - # - #platforms: - #- name: EL - # versions: - # - all - # - 5 - # - 6 - # - 7 - #- name: GenericUNIX - # versions: - # - all - # - any - #- name: Fedora - # versions: - # - all - # - 16 - # - 17 - # - 18 - # - 19 - # - 20 - #- name: opensuse - # versions: - # - all - # - 12.1 - # - 12.2 - # - 12.3 - # - 13.1 - # - 13.2 - #- name: Amazon - # versions: - # - all - # - 2013.03 - # - 2013.09 - #- name: GenericBSD - # versions: - # - all - # - any - #- name: FreeBSD - # versions: - # - all - # - 8.0 - # - 8.1 - # - 8.2 - # - 8.3 - # - 8.4 - # - 9.0 - # - 9.1 - # - 9.1 - # - 9.2 - #- name: Ubuntu - # versions: - # - all - # - lucid - # - maverick - # - natty - # - oneiric - # - precise - # - quantal - # - raring - # - saucy - # - trusty - #- name: SLES - # versions: - # - all - # - 10SP3 - # - 10SP4 - # - 11 - # - 11SP1 - # - 11SP2 - # - 11SP3 - #- name: GenericLinux - # versions: - # - all - # - any - #- name: Debian - # versions: - # - all - # - etch - # - lenny - # - squeeze - # - wheezy - # - # Below are all categories currently available. Just as with - # the platforms above, uncomment those that apply to your role. - # - #categories: - #- cloud - #- cloud:ec2 - #- cloud:gce - #- cloud:rax - #- clustering - #- database - #- database:nosql - #- database:sql - #- development - #- monitoring - #- networking - #- packaging - #- system - #- web -dependencies: [] - # List your role dependencies here, one per line. Only - # dependencies available via galaxy should be listed here. - # Be sure to remove the '[]' above if you add dependencies - # to this list. - diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml deleted file mode 100644 index 062d2e8a9..000000000 --- a/roles/etcd/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: Install etcd - yum: pkg=etcd state=installed disable_gpg_check=yes - -- name: Install etcdctl - yum: pkg=etcdctl state=installed disable_gpg_check=yes - -- name: Write etcd global config file - template: src=etcd.conf.j2 dest=/etc/etcd/etcd.conf - notify: - - restart etcd - -- name: Open firewalld port for etcd - firewalld: port=4001/tcp permanent=false state=enabled - -- name: Save firewalld port for etcd - firewalld: port=4001/tcp permanent=true state=enabled - -- name: Enable etcd - service: name=etcd enabled=yes state=started diff --git a/roles/etcd/templates/etcd.conf.j2 b/roles/etcd/templates/etcd.conf.j2 deleted file mode 100644 index 1b43f6552..000000000 --- a/roles/etcd/templates/etcd.conf.j2 +++ /dev/null @@ -1,34 +0,0 @@ -# This configuration file is written in [TOML](https://github.com/mojombo/toml) - -# addr = "127.0.0.1:4001" -# bind_addr = "127.0.0.1:4001" -# ca_file = "" -# cert_file = "" -# cors = [] -# cpu_profile_file = "" -# data_dir = "." -# discovery = "http://etcd.local:4001/v2/keys/_etcd/registry/examplecluster" -# http_read_timeout = 10 -# http_write_timeout = 10 -# key_file = "" -# peers = [] -# peers_file = "" -# max_cluster_size = 9 -# max_result_buffer = 1024 -# max_retry_attempts = 3 -# name = "default-name" -# snapshot = false -# verbose = false -# very_verbose = false - -# [peer] -# addr = "127.0.0.1:7001" -# bind_addr = "127.0.0.1:7001" -# ca_file = "" -# cert_file = "" -# key_file = "" - -# [cluster] -# active_size = 9 -# remove_delay = 1800.0 -# sync_interval = 5.0 |