Skip to content

Commit

Permalink
Merge pull request #71 from mapuri/ansible
Browse files Browse the repository at this point in the history
vendor the recent ansible repo and a few enhancements
  • Loading branch information
mapuri committed Mar 24, 2016
2 parents b7d4315 + e46b4df commit e925178
Show file tree
Hide file tree
Showing 56 changed files with 507 additions and 158 deletions.
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
demo: stop start
stop:
.PHONY: demo demo-stock help start start-stock stop svc-provision svc-cleanup

.DEFAULT_GOAL := help

help: ## This help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

demo: stop start ## Bring up a demo setup. Tearsdown any existing setup first.

demo-stock: stop start-stock ## Bring up a demo setup with stock OS box. All packages are installed fresh. Useful for testing production like environment. Tearsdown any existing setup first.

stop: ## Teardown a demo setup.
CONTIV_NODES=$${CONTIV_NODES:-3} vagrant destroy -f
start:

start: ## Bring up a demo setup.
CONTIV_NODES=$${CONTIV_NODES:-3} CONTIV_SRV_INIT=1 vagrant up
svc-provision:

start-stock: ## Bring up a demo setup with stock OS box. All packages are installed fresh. Useful for testing production like environment.
CONTIV_BOX="puppetlabs/centos-7.2-64-nocm" CONTIV_BOX_VERSION="1.0.1" make start

svc-provision: ## Rerun ansible provisioning on the exisitng demo setup.
CONTIV_NODES=$${CONTIV_NODES:-3} CONTIV_SRV_INIT=1 \
vagrant provision --provision-with ansible
svc-cleanup:

svc-cleanup: ## Run cleanup ansible on the existing demo setup.
CONTIV_NODES=$${CONTIV_NODES:-3} CONTIV_ANSIBLE_PLAYBOOK="./vendor/ansible/cleanup.yml" \
vagrant provision --provision-with ansible
52 changes: 33 additions & 19 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ if ENV['CONTIV_SRV_INIT'] then
service_init = true
end

box = "contiv/centos72"
if ENV['CONTIV_BOX'] then
box = ENV['CONTIV_BOX']
end

box_version = "0.3.2"
if ENV['CONTIV_BOX_VERSION'] then
box_version = ENV['CONTIV_BOX_VERSION']
end

host_env = { }
if ENV['CONTIV_ENV'] then
ENV['CONTIV_ENV'].split(" ").each do |env|
Expand Down Expand Up @@ -73,8 +83,8 @@ EOF

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "contiv/centos72"
config.vm.box_version = "0.3.0"
config.vm.box = box
config.vm.box_version = box_version
node_ips = num_nodes.times.collect { |n| base_ip + "#{n+10}" }
node_names = num_nodes.times.collect { |n| "cluster-node#{n+1}" }
# this is to avoid the issue: https://github.com/mitchellh/vagrant/issues/5186
Expand Down Expand Up @@ -108,22 +118,26 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
v.customize ['modifyvm', :id, '--nictype3', 'virtio']
v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all']
v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all']
# create disks for ceph
(0..1).each do |d|
disk_path = "disk-#{n}-#{d}"
vdi_disk_path = disk_path + ".vdi"

v.customize ['createhd',
'--filename', disk_path,
'--size', '11000']
# Controller names are dependent on the VM being built.
# It is set when the base box is made in our case ubuntu/trusty64.
# Be careful while changing the box.
v.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', 3 + d,
'--type', 'hdd',
'--medium', vdi_disk_path]
# XXX: creating disk doesn't work in stock centos box, remove this check
# once we need ceph working in stock OS demo
if box == "contiv/centos72" then
# create disks for ceph
(0..1).each do |d|
disk_path = "disk-#{n}-#{d}"
vdi_disk_path = disk_path + ".vdi"

v.customize ['createhd',
'--filename', disk_path,
'--size', '11000']
# Controller names are dependent on the VM being built.
# It is set when the base box is made in our case ubuntu/trusty64.
# Be careful while changing the box.
v.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', 3 + d,
'--type', 'hdd',
'--medium', vdi_disk_path]
end
end
end

Expand Down Expand Up @@ -154,7 +168,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ansible_groups["cluster-control"] = [node_name]
end

if service_init
if service_init then
# Share anything in `shared` to '/shared' on the cluster hosts.
node.vm.synced_folder "shared", "/shared"

Expand Down
2 changes: 1 addition & 1 deletion management/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docker_buildargs:= \
$(if $(HTTPS_PROXY), --build-arg "HTTPS_PROXY=$(HTTPS_PROXY)") \
$(if $(http_proxy), --build-arg "http_proxy=$(http_proxy)") \
$(if $(https_proxy), --build-arg "https_proxy=$(https_proxy)")
docker_img:=cluster-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
docker_img:=cluster-dev
docker_run:=docker run --rm -u `id -un`:`id -un` -v `pwd`:$(work_dir) \
-w $(work_dir) "$(docker_img)"
docker_run_interactive:=docker run -it --rm -u `id -un`:`id -un` -v `pwd`:$(work_dir) \
Expand Down
1 change: 0 additions & 1 deletion management/src/demo/files/cli_test/clusterm

This file was deleted.

1 change: 1 addition & 0 deletions management/src/demo/files/cli_test/clusterm.args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLUSTERM_ARGS="--config /etc/default/clusterm/clusterm.conf.json"
2 changes: 1 addition & 1 deletion management/src/systemtests/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *CliTestSuite) SetUpSuite(c *C) {
s.Assert(c, err, IsNil, Commentf("output: %s", out))
//provide test ansible playbooks and restart cluster-mgr
src := fmt.Sprintf("%s/../demo/files/cli_test/*", pwd)
dst := "/etc/default/"
dst := "/etc/default/clusterm/"
out, err = s.tbn1.RunCommandWithOutput(fmt.Sprintf("sudo cp -rf %s %s", src, dst))
s.Assert(c, err, IsNil, Commentf("output: %s", out))
out, err = tutils.ServiceRestartAndWaitForUp(s.tbn1, "clusterm", 30)
Expand Down
3 changes: 3 additions & 0 deletions vendor/ansible/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Vagrant.configure(2) do |config|
node.vm.provider "virtualbox" do |vb|
vb.customize ['modifyvm', :id, '--memory', "4096"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ['modifyvm', :id, '--paravirtprovider', 'kvm']
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
end

if ansible_groups["devtest"] == nil then
Expand Down
47 changes: 17 additions & 30 deletions vendor/ansible/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,21 @@
tasks:
- include_vars: roles/{{ item }}/defaults/main.yml
with_items:
- "etcd"
- "ucp"
- include: roles/contiv_network/tasks/cleanup.yml
ignore_errors: yes
- include: roles/contiv_storage/tasks/cleanup.yml
ignore_errors: yes
- include: roles/contiv_cluster/tasks/cleanup.yml
ignore_errors: yes
- include: roles/swarm/tasks/cleanup.yml
ignore_errors: yes
- include: roles/ucp/tasks/cleanup.yml
ignore_errors: yes
- include: roles/docker/tasks/cleanup.yml
ignore_errors: yes
- include: roles/etcd/tasks/cleanup.yml
ignore_errors: yes
- include: roles/ucarp/tasks/cleanup.yml
- "contiv_network"
- "contiv_storage"
- "contiv_cluster"
- "swarm"
- "ucp"
- "docker"
- "etcd"
- include: roles/{{ item }}/tasks/cleanup.yml
with_items:
- contiv_network
- contiv_storage
- contiv_cluster
- swarm
- ucp
- docker
- etcd
- ucarp
ignore_errors: yes
# XXX: following syntax is much cleaner but is available only in v2.
# Will move to this once our packer images and hosts have consistently moved to Ansiblev2
#- include: roles/{{ item }}/tasks/cleanup.yml
# with_items:
# - contiv_network
# - contiv_storage
# - contiv_cluster
# - swarm
# - ucp
# - docker
# - etcd
# - ucarp
# ignore_errors: yes
2 changes: 2 additions & 0 deletions vendor/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ validate_certs: "yes"
# env:
# service_vip:
# control_interface:

host_capability: "can-run-user-containers, storage"
20 changes: 20 additions & 0 deletions vendor/ansible/roles/ansible/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# This role contains tasks for installing ansible

- name: install ansible (redhat)
yum:
name: ansible
enablerepo: epel-testing
state: latest
when: ansible_os_family == "RedHat"

- name: add ansible apt repository (debian)
apt_repository:
repo: ppa:ansible/ansible
state: present
validate_certs: "{{ validate_certs }}"
when: ansible_os_family == "Debian"

- name: install ansible (debian)
apt: name=ansible state=latest
when: ansible_os_family == "Debian"
33 changes: 5 additions & 28 deletions vendor/ansible/roles/base/tasks/redhat_tasks.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
- name: upgrade system (redhat)
yum:
update_cache: true
name: '*'
state: latest

# install epel-release first to ensure the extra packages can be installed later
- name: install epel release package (redhat)
yum:
name: epel-release
state: latest

- name: install base packages (redhat)
- name: install/upgrade base packages (redhat)
yum:
name: "{{ item }}"
update_cache: true
state: latest
with_items:
- ntp
- unzip
- bzip2
- vim
- curl
- git
- mercurial
- gcc
- perl
- librbd1-devel
- lshw
- python-requests # XXX required by ceph repo, but it has a bad package on it
- bash-completion
- kernel #keep kernel up to date

- name: install and start ntp
shell: systemctl enable ntpd

- name: install python-crypto
yum: name=python-crypto state=present
register: python_crypto_result
ignore_errors: yes

- name: remove python crypt egg file to work-around https://bugs.centos.org/view.php?id=9896&nbn=2
shell: rm -rf /usr/lib64/python2.7/site-packages/pycrypto-*.egg-info
when: '"Error unpacking rpm package python2-crypto-" in python_crypto_result.msg'

- name: install ansible (redhat)
yum:
name: ansible
enablerepo: epel-testing
state: latest
16 changes: 1 addition & 15 deletions vendor/ansible/roles/base/tasks/ubuntu_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,11 @@
- name: install base packages (debian)
apt:
name: "{{ item }}"
state: latest
with_items:
- unzip
- bzip2
- vim-nox
- curl
- python-software-properties
- git
- mercurial
- build-essential
- perl
- librbd-dev
- lshw
- bash-completion

- name: add ansible apt repository (debian)
apt_repository:
repo: ppa:ansible/ansible
state: present
validate_certs: "{{ validate_certs }}"

- name: install ansible (debian)
apt: name=ansible state=present
12 changes: 12 additions & 0 deletions vendor/ansible/roles/ceph-common/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
apt:
update-cache: yes

- name: check for a ceph socket
shell: "stat /var/run/ceph/*.asok > /dev/null 2>&1"
changed_when: false
failed_when: false
register: socket

- name: check for a rados gateway socket
shell: "stat {{ rbd_client_admin_socket_path }}*.asok > /dev/null 2>&1"
changed_when: false
failed_when: false
register: socketrgw

- name: restart ceph mons
command: service ceph restart mon
when:
Expand Down
14 changes: 2 additions & 12 deletions vendor/ansible/roles/ceph-common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
radosgw_frontend == 'apache' and
rgw_group_name in group_names

- name: check for a ceph socket
shell: "stat /var/run/ceph/*.asok > /dev/null 2>&1"
changed_when: false
failed_when: false
register: socket

- name: check for a rados gateway socket
shell: "stat {{ rbd_client_admin_socket_path }}*.asok > /dev/null 2>&1"
changed_when: false
failed_when: false
register: socketrgw

- name: create a local fetch directory if it doesn't exist
local_action: file path={{ fetch_directory }} state=directory
changed_when: false
Expand Down Expand Up @@ -86,6 +74,8 @@
group: root
mode: 0644
notify:
- check for a ceph socket
- check for a rados gateway socket
- restart ceph mons
- restart ceph mons on ubuntu
- restart ceph mons with systemd
Expand Down
8 changes: 6 additions & 2 deletions vendor/ansible/roles/contiv_cluster/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
# role variable for the cluster manager service

collins_image: contiv/collins:02_25_2016
collins_image: contiv/collins
collins_image_version: "02_25_2016"
collins_host_port: 9000
collins_guest_port: 9000

contiv_cluster_version: "v0.0.0-03-08-2016.00-06-26.UTC"
clusterm_args_file: "clusterm.args"
clusterm_conf_file: "clusterm.conf"

contiv_cluster_version: "v0.0.0-03-13-2016.03-44-45.UTC"
contiv_cluster_tar_file: "cluster-{{ contiv_cluster_version }}.tar.bz2"
contiv_cluster_src_file: "https://github.com/contiv/cluster/releases/download/{{ contiv_cluster_version }}/{{ contiv_cluster_tar_file }}"
contiv_cluster_dest_file: "/tmp/{{ contiv_cluster_tar_file }}"
1 change: 0 additions & 1 deletion vendor/ansible/roles/contiv_cluster/files/clusterm

This file was deleted.

1 change: 1 addition & 0 deletions vendor/ansible/roles/contiv_cluster/files/clusterm.args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLUSTERM_ARGS="--config=/etc/default/clusterm/clusterm.conf"
3 changes: 3 additions & 0 deletions vendor/ansible/roles/contiv_cluster/files/clusterm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"comment" : "empty JSON loads a default clusterm configuration. Add configuration here and restart clusterm service to load non-default configuration"
}
5 changes: 5 additions & 0 deletions vendor/ansible/roles/contiv_cluster/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# The dependecies for cluster-mgr

dependencies:
- { role: ansible }
Loading

0 comments on commit e925178

Please sign in to comment.