summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README_AWS.md4
-rw-r--r--README_libvirt.md10
-rw-r--r--ansible-profile/README.md6
-rw-r--r--ansible-profile/callback_plugins/profile_tasks.py83
-rwxr-xr-xbin/cluster29
-rw-r--r--lookup_plugins/oo_option.py73
-rw-r--r--playbooks/adhoc/noc/create_maintenance.yml36
-rw-r--r--playbooks/adhoc/noc/get_zabbix_problems.yml2
l---------playbooks/libvirt/openshift-cluster/lookup_plugins1
-rw-r--r--playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml1
-rw-r--r--playbooks/libvirt/openshift-cluster/vars.yml9
l---------playbooks/openstack/openshift-cluster/lookup_plugins1
-rw-r--r--playbooks/openstack/openshift-cluster/vars.yml43
-rw-r--r--roles/openshift_master/templates/master.yaml.v1.j26
14 files changed, 274 insertions, 30 deletions
diff --git a/README_AWS.md b/README_AWS.md
index 7f4b1832b..5db36b5cb 100644
--- a/README_AWS.md
+++ b/README_AWS.md
@@ -27,10 +27,10 @@ In case of a cluster creation, or any other case where you don't know the machin
to setup a private key file to allow ansible to connect to the created hosts.
To do so, add the the following entry to your $HOME/.ssh/config file and make it point to the private key file which allows you to login on AWS.
-'''
+```
Host *.compute-1.amazonaws.com
PrivateKey $HOME/.ssh/my_private_key.pem
-'''
+```
Alternatively, you can configure your ssh-agent to hold the credentials to connect to your AWS instances.
diff --git a/README_libvirt.md b/README_libvirt.md
index 92f0b3dc9..60af0ac88 100644
--- a/README_libvirt.md
+++ b/README_libvirt.md
@@ -102,6 +102,16 @@ Test The Setup
bin/cluster list libvirt ''
```
+Configuration
+-------------
+
+The following options can be passed via the `-o` flag of the `create` command or as environment variables:
+
+* `image_url` (default to `http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2`): URL of the QCOW2 image to download
+* `image_name` (default to `CentOS-7-x86_64-GenericCloud.qcow2`): Name of the QCOW2 image to boot the VMs on
+* `image_sha256` (default to `e324e3ab1d24a1bbf035ddb365e7f9058c0b454acf48d7aa15c5519fae5998ab`): Expected SHA256 checksum of the downloaded image
+* `skip_image_download` (default to `no`): Skip QCOW2 image download. This requires the `image_name` QCOW2 image to be already present in `$HOME/libvirt-storage-pool-openshift-ansible`
+
Creating a cluster
------------------
diff --git a/ansible-profile/README.md b/ansible-profile/README.md
new file mode 100644
index 000000000..4f10817d4
--- /dev/null
+++ b/ansible-profile/README.md
@@ -0,0 +1,6 @@
+# Ansible profile
+
+This is a callback plugin for timing tasks.
+
+The upstream project lies in:
+https://github.com/jlafon/ansible-profile
diff --git a/ansible-profile/callback_plugins/profile_tasks.py b/ansible-profile/callback_plugins/profile_tasks.py
new file mode 100644
index 000000000..e9728a803
--- /dev/null
+++ b/ansible-profile/callback_plugins/profile_tasks.py
@@ -0,0 +1,83 @@
+# The MIT License (MIT)
+
+# Copyright (c) 2014 Jharrod LaFon
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal in
+# the Software without restriction, including without limitation the rights to
+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+# the Software, and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'''
+A plugin for timing tasks
+
+This plugin records the time spent in each task.
+At the end of the playbook, it displays the time spent in the 10 slowest tasks.
+'''
+
+import time
+
+
+class CallbackModule(object):
+ """
+ A plugin for timing tasks
+ """
+ def __init__(self):
+ self.stats = {}
+ self.current = None
+
+ # Reason: The is_conditional parameter is part of the Ansible plugin API
+ # Status: permanently disabled
+ # pylint: disable=unused-argument
+ def playbook_on_task_start(self, name, is_conditional):
+ """
+ Logs the start of each task
+ """
+ if self.current is not None:
+ # Record the running time of the last executed task
+ self.stats[self.current] = time.time() - self.stats[self.current]
+
+ # Record the start time of the current task
+ self.current = name
+ self.stats[self.current] = time.time()
+
+ # Reason: The stats parameter is part of the Ansible plugin API
+ # Status: permanently disabled
+ # pylint: disable=unused-argument
+ def playbook_on_stats(self, stats):
+ """
+ Prints the timings
+ """
+ # Record the timing of the very last task
+ if self.current is not None:
+ self.stats[self.current] = time.time() - self.stats[self.current]
+
+ # Sort the tasks by their running time
+ results = sorted(
+ self.stats.items(),
+ key=lambda value: value[1],
+ reverse=True,
+ )
+
+ # Just keep the top 10
+ results = results[:10]
+
+ # Print the timings
+ for name, elapsed in results:
+ print(
+ "{0:-<70}{1:->9}".format(
+ '{0} '.format(name),
+ ' {0:.02f}s'.format(elapsed),
+ )
+ )
diff --git a/bin/cluster b/bin/cluster
index 2ea389523..fbbffadc9 100755
--- a/bin/cluster
+++ b/bin/cluster
@@ -3,8 +3,9 @@
import argparse
import ConfigParser
-import sys
import os
+import sys
+import traceback
class Cluster(object):
@@ -141,6 +142,11 @@ class Cluster(object):
os.environ[key] = config.get('ec2', key)
inventory = '-i inventory/aws/hosts'
+
+ missing = [key for key in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'] if key not in os.environ]
+ if len(missing) > 0:
+ raise ValueError("PROVIDER aws requires {} environment variable(s). See README_AWS.md".format(missing))
+
elif 'libvirt' == provider:
inventory = '-i inventory/libvirt/hosts'
elif 'openstack' == provider:
@@ -168,7 +174,7 @@ class Cluster(object):
if args.option:
for opt in args.option:
k, v = opt.split('=', 1)
- env['opt_'+k] = v
+ env['cli_' + k] = v
ansible_env = '-e \'{}\''.format(
' '.join(['%s=%s' % (key, value) for (key, value) in env.items()])
@@ -178,6 +184,9 @@ class Cluster(object):
verbose, inventory, ansible_env, playbook
)
+ if args.profile:
+ command = 'ANSIBLE_CALLBACK_PLUGINS=ansible-profile/callback_plugins ' + command
+
if args.verbose > 1:
command = 'time {}'.format(command)
@@ -234,6 +243,9 @@ if __name__ == '__main__':
meta_parser.add_argument('-o', '--option', action='append',
help='options')
+ meta_parser.add_argument('-p', '--profile', action='store_true',
+ help='Enable playbook profiling')
+
action_parser = parser.add_subparsers(dest='action', title='actions',
description='Choose from valid actions')
@@ -290,7 +302,14 @@ if __name__ == '__main__':
sys.stderr.write('\nACTION [update] aborted by user!\n')
exit(1)
- status = args.func(args)
- if status != 0:
- sys.stderr.write("ACTION [{}] failed with exit status {}\n".format(args.action, status))
+ status = 1
+ try:
+ status = args.func(args)
+ if status != 0:
+ sys.stderr.write("ACTION [{}] failed with exit status {}\n".format(args.action, status))
+ except Exception, e:
+ if args.verbose:
+ traceback.print_exc(file=sys.stderr)
+ else:
+ sys.stderr.write("{}\n".format(e))
exit(status)
diff --git a/lookup_plugins/oo_option.py b/lookup_plugins/oo_option.py
new file mode 100644
index 000000000..35dce48f9
--- /dev/null
+++ b/lookup_plugins/oo_option.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+# vim: expandtab:tabstop=4:shiftwidth=4
+
+'''
+oo_option lookup plugin for openshift-ansible
+
+Usage:
+
+ - debug:
+ msg: "{{ lookup('oo_option', '<key>') | default('<default_value>', True) }}"
+
+This returns, by order of priority:
+
+* if it exists, the `cli_<key>` ansible variable. This variable is set by `bin/cluster --option <key>=<value> …`
+* if it exists, the envirnoment variable named `<key>`
+* if none of the above conditions are met, empty string is returned
+'''
+
+from ansible.utils import template
+import os
+
+# Reason: disable too-few-public-methods because the `run` method is the only
+# one required by the Ansible API
+# Status: permanently disabled
+# pylint: disable=too-few-public-methods
+class LookupModule(object):
+ ''' oo_option lookup plugin main class '''
+
+ # Reason: disable unused-argument because Ansible is calling us with many
+ # parameters we are not interested in.
+ # The lookup plugins of Ansible have this kwargs “catch-all” parameter
+ # which is not used
+ # Status: permanently disabled unless Ansible API evolves
+ # pylint: disable=unused-argument
+ def __init__(self, basedir=None, **kwargs):
+ ''' Constructor '''
+ self.basedir = basedir
+
+ # Reason: disable unused-argument because Ansible is calling us with many
+ # parameters we are not interested in.
+ # The lookup plugins of Ansible have this kwargs “catch-all” parameter
+ # which is not used
+ # Status: permanently disabled unless Ansible API evolves
+ # pylint: disable=unused-argument
+ def run(self, terms, inject=None, **kwargs):
+ ''' Main execution path '''
+
+ try:
+ terms = template.template(self.basedir, terms, inject)
+ # Reason: disable broad-except to really ignore any potential exception
+ # This is inspired by the upstream "env" lookup plugin:
+ # https://github.com/ansible/ansible/blob/devel/v1/ansible/runner/lookup_plugins/env.py#L29
+ # pylint: disable=broad-except
+ except Exception:
+ pass
+
+ if isinstance(terms, basestring):
+ terms = [terms]
+
+ ret = []
+
+ for term in terms:
+ option_name = term.split()[0]
+ cli_key = 'cli_' + option_name
+ if inject and cli_key in inject:
+ ret.append(inject[cli_key])
+ elif option_name in os.environ:
+ ret.append(os.environ[option_name])
+ else:
+ ret.append('')
+
+ return ret
diff --git a/playbooks/adhoc/noc/create_maintenance.yml b/playbooks/adhoc/noc/create_maintenance.yml
new file mode 100644
index 000000000..c0ec57ce1
--- /dev/null
+++ b/playbooks/adhoc/noc/create_maintenance.yml
@@ -0,0 +1,36 @@
+---
+#ansible-playbook -e 'oo_desc=kwoodson test' -e 'oo_name=kwoodson test name' -e 'oo_start=1435715357' -e 'oo_stop=1435718985' -e 'oo_hostids=11549' create_maintenance.yml
+- name: 'Create a maintenace object in zabbix'
+ hosts: localhost
+ gather_facts: no
+ roles:
+ - os_zabbix
+ vars:
+ oo_hostids: ''
+ oo_groupids: ''
+ post_tasks:
+ - assert:
+ that: oo_desc is defined
+
+ - zbxapi:
+ server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
+ zbx_class: Maintenance
+ state: present
+ params:
+ name: "{{ oo_name }}"
+ description: "{{ oo_desc }}"
+ active_since: "{{ oo_start }}"
+ active_till: "{{ oo_stop }}"
+ maintenance_type: "0"
+ output: extend
+ hostids: "{{ oo_hostids.split(',') | default([]) }}"
+#groupids: "{{ oo_groupids.split(',') | default([]) }}"
+ timeperiods:
+ - start_time: "{{ oo_start }}"
+ period: "{{ oo_stop }}"
+ selectTimeperiods: extend
+
+ register: maintenance
+
+ - debug: var=maintenance
+
diff --git a/playbooks/adhoc/noc/get_zabbix_problems.yml b/playbooks/adhoc/noc/get_zabbix_problems.yml
index 02bffc1d2..4b94fa228 100644
--- a/playbooks/adhoc/noc/get_zabbix_problems.yml
+++ b/playbooks/adhoc/noc/get_zabbix_problems.yml
@@ -11,7 +11,7 @@
- zbxapi:
server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
zbx_class: Trigger
- action: get
+ state: list
params:
only_true: true
output: extend
diff --git a/playbooks/libvirt/openshift-cluster/lookup_plugins b/playbooks/libvirt/openshift-cluster/lookup_plugins
new file mode 120000
index 000000000..ac79701db
--- /dev/null
+++ b/playbooks/libvirt/openshift-cluster/lookup_plugins
@@ -0,0 +1 @@
+../../../lookup_plugins \ No newline at end of file
diff --git a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
index 8291192ab..4cb494056 100644
--- a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
+++ b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
@@ -14,6 +14,7 @@
url: '{{ image_url }}'
sha256sum: '{{ image_sha256 }}'
dest: '{{ os_libvirt_storage_pool_path }}/{{ image_name }}'
+ when: '{{ ( lookup("oo_option", "skip_image_download") | default("no", True) | lower ) in ["false", "no"] }}'
- name: Create the cloud-init config drive path
file:
diff --git a/playbooks/libvirt/openshift-cluster/vars.yml b/playbooks/libvirt/openshift-cluster/vars.yml
index 65d954fee..e3c8cd8d0 100644
--- a/playbooks/libvirt/openshift-cluster/vars.yml
+++ b/playbooks/libvirt/openshift-cluster/vars.yml
@@ -7,9 +7,12 @@ libvirt_uri: 'qemu:///system'
deployment_vars:
origin:
image:
- url: "http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
- name: CentOS-7-x86_64-GenericCloud.qcow2
- sha256: e324e3ab1d24a1bbf035ddb365e7f9058c0b454acf48d7aa15c5519fae5998ab
+ url: "{{ lookup('oo_option', 'image_url') |
+ default('http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2', True) }}"
+ name: "{{ lookup('oo_option', 'image_name') |
+ default('CentOS-7-x86_64-GenericCloud.qcow2', True) }}"
+ sha256: "{{ lookup('oo_option', 'image_sha256') |
+ default('e324e3ab1d24a1bbf035ddb365e7f9058c0b454acf48d7aa15c5519fae5998ab', True) }}"
ssh_user: openshift
sudo: yes
online:
diff --git a/playbooks/openstack/openshift-cluster/lookup_plugins b/playbooks/openstack/openshift-cluster/lookup_plugins
new file mode 120000
index 000000000..ac79701db
--- /dev/null
+++ b/playbooks/openstack/openshift-cluster/lookup_plugins
@@ -0,0 +1 @@
+../../../lookup_plugins \ No newline at end of file
diff --git a/playbooks/openstack/openshift-cluster/vars.yml b/playbooks/openstack/openshift-cluster/vars.yml
index c754f19fc..1ae7c17d2 100644
--- a/playbooks/openstack/openshift-cluster/vars.yml
+++ b/playbooks/openstack/openshift-cluster/vars.yml
@@ -1,27 +1,36 @@
---
-openstack_infra_heat_stack: "{{ opt_infra_heat_stack | default('files/heat_stack.yml') }}"
-openstack_network_prefix: "{{ opt_network_prefix | default('openshift-ansible-'+cluster_id) }}"
-openstack_network_cidr: "{{ opt_net_cidr | default('192.168.' + ( ( 1048576 | random % 256 ) | string() ) + '.0/24') }}"
-openstack_network_external_net: "{{ opt_external_net | default('external') }}"
-openstack_floating_ip_pools: "{{ opt_floating_ip_pools | default('external') | oo_split() }}"
-openstack_network_dns: "{{ opt_dns | default('8.8.8.8,8.8.4.4') | oo_split() }}"
-openstack_ssh_keypair: "{{ opt_keypair | default(lookup('env', 'LOGNAME')+'_key') }}"
-openstack_ssh_public_key: "{{ lookup('file', opt_public_key | default('~/.ssh/id_rsa.pub')) }}"
-openstack_ssh_access_from: "{{ opt_ssh_from | default('0.0.0.0/0') }}"
+openstack_infra_heat_stack: "{{ lookup('oo_option', 'infra_heat_stack' ) |
+ default('files/heat_stack.yml', True) }}"
+openstack_network_prefix: "{{ lookup('oo_option', 'network_prefix' ) |
+ default('openshift-ansible-'+cluster_id, True) }}"
+openstack_network_cidr: "{{ lookup('oo_option', 'net_cidr' ) |
+ default('192.168.' + ( ( 1048576 | random % 256 ) | string() ) + '.0/24', True) }}"
+openstack_network_external_net: "{{ lookup('oo_option', 'external_net' ) |
+ default('external', True) }}"
+openstack_floating_ip_pools: "{{ lookup('oo_option', 'floating_ip_pools') |
+ default('external', True) | oo_split() }}"
+openstack_network_dns: "{{ lookup('oo_option', 'dns' ) |
+ default('8.8.8.8,8.8.4.4', True) | oo_split() }}"
+openstack_ssh_keypair: "{{ lookup('oo_option', 'keypair' ) |
+ default(lookup('env', 'LOGNAME')+'_key', True) }}"
+openstack_ssh_public_key: "{{ lookup('file', lookup('oo_option', 'public_key') |
+ default('~/.ssh/id_rsa.pub', True)) }}"
+openstack_ssh_access_from: "{{ lookup('oo_option', 'ssh_from') |
+ default('0.0.0.0/0', True) }}"
openstack_flavor:
master:
- ram: "{{ opt_master_flavor_ram | default(2048) }}"
- id: "{{ opt_master_flavor_id | default() }}"
- include: "{{ opt_master_flavor_include | default() }}"
+ ram: "{{ lookup('oo_option', 'master_flavor_ram' ) | default(2048, True) }}"
+ id: "{{ lookup('oo_option', 'master_flavor_id' ) | default(True) }}"
+ include: "{{ lookup('oo_option', 'master_flavor_include') | default(True) }}"
node:
- ram: "{{ opt_node_flavor_ram | default(4096) }}"
- id: "{{ opt_node_flavor_id | default() }}"
- include: "{{ opt_node_flavor_include | default() }}"
+ ram: "{{ lookup('oo_option', 'node_flavor_ram' ) | default(4096, True) }}"
+ id: "{{ lookup('oo_option', 'node_flavor_id' ) | default(True) }}"
+ include: "{{ lookup('oo_option', 'node_flavor_include' ) | default(True) }}"
deployment_vars:
origin:
image:
- name: "{{ opt_image_name | default('centos-70-raw') }}"
+ name: "{{ lookup('oo_option', 'image_name') | default('centos-70-raw', True) }}"
id:
ssh_user: openshift
sudo: yes
@@ -33,7 +42,7 @@ deployment_vars:
sudo: no
enterprise:
image:
- name: "{{ opt_image_name | default('centos-70-raw') }}"
+ name: "{{ lookup('oo_option', 'image_name') | default('rhel-guest-image-7.1-20150224.0.x86_64', True) }}"
id:
ssh_user: openshift
sudo: yes
diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2
index 9df07e925..3b8b18c39 100644
--- a/roles/openshift_master/templates/master.yaml.v1.j2
+++ b/roles/openshift_master/templates/master.yaml.v1.j2
@@ -100,6 +100,8 @@ projectConfig:
mcsAllocatorRange: s0:/2
mcsLabelsPerProject: 5
uidAllocatorRange: 1000000000-1999999999/10000
+routingConfig:
+ subdomain: router.default.local
serviceAccountConfig:
managedNames:
- default
@@ -113,5 +115,5 @@ servingInfo:
certFile: master.server.crt
clientCA: ca.crt
keyFile: master.server.key
- maxRequestsInFlight: 0
- requestTimeoutSeconds: 0
+ maxRequestsInFlight: 500
+ requestTimeoutSeconds: 3600