summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rwxr-xr-xbin/cluster30
-rw-r--r--docs/best_practices_guide.adoc46
-rw-r--r--playbooks/aws/openshift-cluster/service.yml28
-rw-r--r--playbooks/common/openshift-master/service.yml18
-rw-r--r--playbooks/common/openshift-node/service.yml18
-rw-r--r--playbooks/gce/openshift-cluster/service.yml28
-rw-r--r--playbooks/gce/openshift-cluster/wip.yml26
-rw-r--r--playbooks/libvirt/openshift-cluster/service.yml32
-rw-r--r--roles/kube_nfs_volumes/README.md2
-rw-r--r--roles/pods/meta/main.yml6
11 files changed, 232 insertions, 13 deletions
diff --git a/README.md b/README.md
index 08ee3513a..2ea147e46 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,8 @@
-openshift-ansible
-========================
+#openshift-ansible
This repo contains OpenShift Ansible code.
-Setup
------
+##Setup
- Install base dependencies:
- Fedora:
```
@@ -36,3 +34,8 @@ Setup
- [inventory/](inventory) - houses Ansible dynamic inventory scripts
- [playbooks/](playbooks) - houses host-type Ansible playbooks (launch, config, destroy, vars)
- [roles/](roles) - shareable Ansible tasks
+
+##Contributing
+
+###Feature Roadmap
+Our Feature Roadmap is available in our public [Trello board](https://trello.com/b/Qb18IWHF/openshift-ansible)
diff --git a/bin/cluster b/bin/cluster
index 79f1f988f..2a6cb4b58 100755
--- a/bin/cluster
+++ b/bin/cluster
@@ -9,8 +9,9 @@ import os
class Cluster(object):
"""
- Control and Configuration Interface for OpenShift Clusters
+ Provide Command, Control and Configuration (c3) Interface for OpenShift Clusters
"""
+
def __init__(self):
# setup ansible ssh environment
if 'ANSIBLE_SSH_ARGS' not in os.environ:
@@ -104,6 +105,21 @@ class Cluster(object):
return self.action(args, inventory, env, playbook)
+ def service(self, args):
+ """
+ Make the same service call across all nodes in the cluster
+ :param args: command line arguments provided by user
+ :return: exit status from run command
+ """
+ env = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'new_cluster_state': args.state}
+
+ playbook = "playbooks/{}/openshift-cluster/service.yml".format(args.provider)
+ inventory = self.setup_provider(args.provider)
+
+ return self.action(args, inventory, env, playbook)
+
def setup_provider(self, provider):
"""
Setup ansible playbook environment
@@ -167,7 +183,7 @@ class Cluster(object):
if __name__ == '__main__':
"""
- Implemented to support writing unit tests
+ User command to invoke ansible playbooks in a "known" environment
"""
cluster = Cluster()
@@ -221,6 +237,13 @@ if __name__ == '__main__':
parents=[meta_parser])
list_parser.set_defaults(func=cluster.list)
+ service_parser = action_parser.add_parser('service', help='service for openshift across cluster',
+ parents=[meta_parser])
+ # choices are the only ones valid for the ansible service module: http://docs.ansible.com/service_module.html
+ service_parser.add_argument('state', choices=['started', 'stopped', 'restarted', 'reloaded'],
+ help='make service call across cluster')
+ service_parser.set_defaults(func=cluster.service)
+
args = parser.parse_args()
if 'terminate' == args.action and not args.force:
@@ -230,7 +253,8 @@ if __name__ == '__main__':
exit(1)
if 'update' == args.action and not args.force:
- answer = raw_input("This is destructive and could corrupt {} environment. Continue? [y/N] ".format(args.cluster_id))
+ answer = raw_input(
+ "This is destructive and could corrupt {} environment. Continue? [y/N] ".format(args.cluster_id))
if answer not in ['y', 'Y']:
sys.stderr.write('\nACTION [update] aborted by user!\n')
exit(1)
diff --git a/docs/best_practices_guide.adoc b/docs/best_practices_guide.adoc
index af1acd94f..2768059b3 100644
--- a/docs/best_practices_guide.adoc
+++ b/docs/best_practices_guide.adoc
@@ -19,7 +19,6 @@ This guide complies with https://www.ietf.org/rfc/rfc2119.txt[RFC2119].
| All pull requests MUST pass the build bot *before* they are merged.
|===
-
The purpose of this rule is to avoid cases where the build bot will fail pull requests for code modified in a previous pull request.
The tooling is flexible enough that exceptions can be made so that the tool the build bot is running will ignore certain areas or certain checks, but the build bot itself must pass for the pull request to be merged.
@@ -79,6 +78,49 @@ metadata[line] = results.pop()
== Ansible
+=== Defensive Programming
+
+.Context
+* http://docs.ansible.com/fail_module.html[Ansible Fail Module]
+
+'''
+[cols="2v,v"]
+|===
+| **Rule**
+| Ansible playbooks MUST begin with checks for any variables that they require.
+|===
+
+If an Ansible playbook requires certain variables to be set, it's best to check for these up front before any other actions have been performed. In this way, the user knows exactly what needs to be passed into the playbook.
+
+.Example:
+[source,yaml]
+----
+---
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="This playbook requires g_environment to be set and non empty"
+ when: g_environment is not defined or g_environment == ''
+----
+
+'''
+[cols="2v,v"]
+|===
+| **Rule**
+| Ansible roles tasks/main.yml file MUST begin with checks for any variables that they require.
+|===
+
+If an Ansible role requires certain variables to be set, it's best to check for these up front before any other actions have been performed. In this way, the user knows exactly what needs to be passed into the role.
+
+.Example:
+[source,yaml]
+----
+---
+# tasks/main.yml
+- fail: msg="This role requires arl_environment to be set and non empty"
+ when: arl_environment is not defined or arl_environment == ''
+----
+
=== Roles
.Context
* http://docs.ansible.com/playbooks_best_practices.html#directory-layout[Ansible Suggested Directory Layout]
@@ -102,7 +144,7 @@ metadata[line] = results.pop()
| Ansible Roles SHOULD be named like technology_component[_subcomponent].
|===
-For clarity, it is suggested to follow a pattern when naming roles. It is important to note that this is a recommendation for role naming, and follows the pattern used by upstream.
+For consistency, role names SHOULD follow the above naming pattern. It is important to note that this is a recommendation for role naming, and follows the pattern used by upstream.
Many times the `technology` portion of the pattern will line up with a package name. It is advised that whenever possible, the package name should be used.
diff --git a/playbooks/aws/openshift-cluster/service.yml b/playbooks/aws/openshift-cluster/service.yml
new file mode 100644
index 000000000..25cf48505
--- /dev/null
+++ b/playbooks/aws/openshift-cluster/service.yml
@@ -0,0 +1,28 @@
+---
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - name: Evaluate g_service_masters
+ add_host:
+ name: "{{ item }}"
+ groups: g_service_masters
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-master"] | default([])
+
+ - name: Evaluate g_service_nodes
+ add_host:
+ name: "{{ item }}"
+ groups: g_service_nodes
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type_{{ cluster_id }}-openshift-node"] | default([])
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/playbooks/common/openshift-master/service.yml b/playbooks/common/openshift-master/service.yml
new file mode 100644
index 000000000..5636ad156
--- /dev/null
+++ b/playbooks/common/openshift-master/service.yml
@@ -0,0 +1,18 @@
+---
+- name: Populate g_service_masters host group if needed
+ hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="new_cluster_state is required to be injected in this playbook"
+ when: new_cluster_state is not defined
+
+ - name: Evaluate g_service_masters
+ add_host: name={{ item }} groups=g_service_masters
+ with_items: oo_host_group_exp | default([])
+
+- name: Change openshift-master state on master instance(s)
+ hosts: g_service_masters
+ connection: ssh
+ gather_facts: no
+ tasks:
+ - service: name=openshift-master state="{{ new_cluster_state }}"
diff --git a/playbooks/common/openshift-node/service.yml b/playbooks/common/openshift-node/service.yml
new file mode 100644
index 000000000..f76df089f
--- /dev/null
+++ b/playbooks/common/openshift-node/service.yml
@@ -0,0 +1,18 @@
+---
+- name: Populate g_service_nodes host group if needed
+ hosts: localhost
+ gather_facts: no
+ tasks:
+ - fail: msg="new_cluster_state is required to be injected in this playbook"
+ when: new_cluster_state is not defined
+
+ - name: Evaluate g_service_nodes
+ add_host: name={{ item }} groups=g_service_nodes
+ with_items: oo_host_group_exp | default([])
+
+- name: Change openshift-node state on node instance(s)
+ hosts: g_service_nodes
+ connection: ssh
+ gather_facts: no
+ tasks:
+ - service: name=openshift-node state="{{ new_cluster_state }}"
diff --git a/playbooks/gce/openshift-cluster/service.yml b/playbooks/gce/openshift-cluster/service.yml
new file mode 100644
index 000000000..2d0f2ab95
--- /dev/null
+++ b/playbooks/gce/openshift-cluster/service.yml
@@ -0,0 +1,28 @@
+---
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-node
+ - add_host:
+ name: "{{ item }}"
+ groups: g_service_nodes
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
+
+ - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-master
+ - add_host:
+ name: "{{ item }}"
+ groups: g_service_masters
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/playbooks/gce/openshift-cluster/wip.yml b/playbooks/gce/openshift-cluster/wip.yml
new file mode 100644
index 000000000..51a521a6b
--- /dev/null
+++ b/playbooks/gce/openshift-cluster/wip.yml
@@ -0,0 +1,26 @@
+---
+- name: WIP
+ hosts: localhost
+ connection: local
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - name: Evaluate oo_masters_for_deploy
+ add_host:
+ name: "{{ item }}"
+ groups: oo_masters_for_deploy
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-master"] | default([])
+
+- name: Deploy OpenShift Services
+ hosts: oo_masters_for_deploy
+ connection: ssh
+ gather_facts: yes
+ user: root
+ vars_files:
+ - vars.yml
+ roles:
+ - openshift_registry
+ - openshift_router
diff --git a/playbooks/libvirt/openshift-cluster/service.yml b/playbooks/libvirt/openshift-cluster/service.yml
new file mode 100644
index 000000000..ae095f5a2
--- /dev/null
+++ b/playbooks/libvirt/openshift-cluster/service.yml
@@ -0,0 +1,32 @@
+---
+# TODO: need to figure out a plan for setting hostname, currently the default
+# is localhost, so no hostname value (or public_hostname) value is getting
+# assigned
+
+- name: Call same systemctl command for openshift on all instance(s)
+ hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars.yml
+ tasks:
+ - fail: msg="cluster_id is required to be injected in this playbook"
+ when: cluster_id is not defined
+
+ - name: Evaluate g_service_masters
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: g_service_masters
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-master"] | default([])
+
+ - name: Evaluate g_service_nodes
+ add_host:
+ name: "{{ item }}"
+ ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}"
+ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
+ groups: g_service_nodes
+ with_items: groups["tag_env-host-type-{{ cluster_id }}-openshift-node"] | default([])
+
+- include: ../../common/openshift-node/service.yml
+- include: ../../common/openshift-master/service.yml
diff --git a/roles/kube_nfs_volumes/README.md b/roles/kube_nfs_volumes/README.md
index 965958bd6..56c69c286 100644
--- a/roles/kube_nfs_volumes/README.md
+++ b/roles/kube_nfs_volumes/README.md
@@ -33,7 +33,7 @@ disks: /dev/sdb,/dev/sdc
# Whether to re-partition already partitioned disks.
# Even though the disks won't get repartitioned on 'false', all existing
# partitions on the disk are exported via NFS as physical volumes!
-foce: false
+force: false
# Specification of size of partitions to create. See library/partitionpool.py
# for details.
diff --git a/roles/pods/meta/main.yml b/roles/pods/meta/main.yml
index c5c362c60..bddf14bb2 100644
--- a/roles/pods/meta/main.yml
+++ b/roles/pods/meta/main.yml
@@ -1,7 +1,7 @@
---
galaxy_info:
author: your name
- description:
+ description:
company: your company (optional)
# Some suggested licenses:
# - BSD (default)
@@ -14,7 +14,7 @@ galaxy_info:
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
+ # 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:
@@ -121,4 +121,4 @@ dependencies: []
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
# to this list.
-
+