Skip to content

Commit

Permalink
Merge pull request #46 from mapuri/ansible
Browse files Browse the repository at this point in the history
vendor recent changes in contiv/ansible repo
  • Loading branch information
mapuri committed Feb 6, 2016
2 parents 624fa17 + acaaa19 commit acbe606
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 50 deletions.
3 changes: 3 additions & 0 deletions management/src/systemtests/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (s *CliTestSuite) TearDownSuite(c *C) {
return
}
s.tbn1 = nil
s.tbn2 = nil
s.tb.Teardown()
}

Expand All @@ -125,6 +126,8 @@ func (s *CliTestSuite) SetUpTest(c *C) {
file := dummyAnsibleFile
out, err := s.tbn1.RunCommandWithOutput(fmt.Sprintf("rm %s", file))
c.Logf("dummy file cleanup. Error: %s, Output: %s", err, out)
out, err = s.tbn2.RunCommandWithOutput(fmt.Sprintf("rm %s", file))
c.Logf("dummy file cleanup. Error: %s, Output: %s", err, out)

// XXX: we cleanup up assets from collins instead of restarting it to save test time.
for _, name := range validNodeNames {
Expand Down
5 changes: 5 additions & 0 deletions vendor/ansible/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- include_vars: roles/{{ item }}/vars/main.yml
with_items:
- "etcd"
- include_vars: roles/{{ item }}/defaults/main.yml
with_items:
- "ucp"
- include: roles/contiv_network/tasks/cleanup.yml
ignore_errors: yes
- include: roles/contiv_storage/tasks/cleanup.yml
Expand All @@ -17,6 +20,8 @@
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
Expand Down
1 change: 1 addition & 0 deletions vendor/ansible/roles/base/tasks/redhat_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- librbd1-devel
- lshw
- python-requests # XXX required by ceph repo, but it has a bad package on it
- bash-completion

- name: install and start ntp
shell: systemctl enable ntpd
Expand Down
1 change: 1 addition & 0 deletions vendor/ansible/roles/base/tasks/ubuntu_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- perl
- librbd-dev
- lshw
- bash-completion

- name: add ansible apt repository (debian)
apt_repository:
Expand Down
2 changes: 2 additions & 0 deletions vendor/ansible/roles/contiv_network/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# Include variables which need to be overridden by inventory vars here.

contiv_network_mode: "standalone" # Accepted values: standalone, aci
netplugin_mode: "docker" # Accepted values: docker, kubernetes
fwd_mode: "bridge" #Accepted values: bridge , routing
1 change: 0 additions & 1 deletion vendor/ansible/roles/contiv_network/files/netplugin

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/ansible/roles/contiv_network/tasks/aci_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
run_once: true

- name: set aci mode
shell: contivctl global set -nwinfra aci
shell: contivctl net global set --fabric-mode aci
run_once: true
24 changes: 19 additions & 5 deletions vendor/ansible/roles/contiv_network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,35 @@
- name: download netmaster and netplugin
get_url:
validate_certs: "{{ validate_certs }}"
url: https://github.com/contiv/netplugin/releases/download/v0.0.0-12-11-2015.20-54-40.UTC/netplugin-v0.0.0-12-11-2015.20-54-40.UTC.tar.bz2
url: https://github.com/contiv/netplugin/releases/download/v0.1-01-28-2016.03-55-05.UTC/netplugin-v0.1-01-28-2016.03-55-05.UTC.tar.bz2
dest: /tmp/contivnet.tar.bz2

- name: ensure netplugin directory exists
file: path=/usr/bin/contiv/netplugin state=directory

- name: install netmaster and netplugin
shell: tar vxjf /tmp/contivnet.tar.bz2
args:
chdir: /usr/bin/
chdir: /usr/bin/contiv/netplugin
creates: netmaster

- name: create links for netplugin binaries
file: src=/usr/bin/contiv/netplugin/{{ item }} dest=/usr/bin/{{ item }} state=link
with_items:
- netctl
- netmaster
- netplugin
- contivk8s

- name: copy environment file for netplugin
template: src=netplugin.j2 dest=/etc/default/netplugin

- name: copy systemd units for netplugin
copy: src=netplugin.service dest=/etc/systemd/system/netplugin.service

- name: copy bash auto complete file for netctl
file: src=/usr/bin/contiv/netplugin/contrib/completion/bash/netctl dest=/etc/bash_completion.d/netctl state=link

- name: start netplugin
shell: systemctl daemon-reload && systemctl start netplugin

Expand All @@ -59,12 +73,12 @@
- name: download contivctl
get_url:
validate_certs: "{{ validate_certs }}"
url: https://github.com/contiv/contivctl/releases/download/v0.0.0-01-14-2016.01-27-38.UTC/contivctl-v0.0.0-01-14-2016.01-27-38.UTC.tar.bz2
dest: /tmp/contivctl-v0.0.0-01-14-2016.01-27-38.UTC.tar.bz2
url: https://github.com/contiv/contivctl/releases/download/v0.0.0-01-31-2016.17-56-53.UTC/contivctl-v0.0.0-01-31-2016.17-56-53.UTC.tar.bz2
dest: /tmp/contivctl-v0.0.0-01-31-2016.17-56-53.UTC.tar.bz2
force: no

- name: install contivctl
shell: tar vxjf /tmp/contivctl-v0.0.0-01-14-2016.01-27-38.UTC.tar.bz2
shell: tar vxjf /tmp/contivctl-v0.0.0-01-31-2016.17-56-53.UTC.tar.bz2
args:
chdir: /usr/bin/
creates: contivctl
Expand Down
8 changes: 4 additions & 4 deletions vendor/ansible/roles/contiv_network/templates/aci_gw.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ start)
set -e

/usr/bin/docker run --net=host \
-e "APIC_URL: {{ apic_url }}" \
-e "APIC_USERNAME: {{ apic_username }}" \
-e "APIC_PASSWORD: {{ apic_password }}" \
-e "APIC_LEAF_NODE: {{ apic_leaf_nodes }}" \
-e "APIC_URL={{ apic_url }}" \
-e "APIC_USERNAME={{ apic_username }}" \
-e "APIC_PASSWORD={{ apic_password }}" \
-e "APIC_LEAF_NODE={{ apic_leaf_nodes }}" \
--name=contiv-aci-gw \
contiv/aci-gw
;;
Expand Down
2 changes: 1 addition & 1 deletion vendor/ansible/roles/contiv_network/templates/netplugin.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NETPLUGIN_ARGS='-docker-plugin -vlan-if {{netplugin_if}} -vtep-ip {{node_addr}}'
NETPLUGIN_ARGS='-plugin-mode {{netplugin_mode}} -vlan-if {{netplugin_if}} -vtep-ip {{node_addr}} -fwd-mode {{fwd_mode}}'
2 changes: 2 additions & 0 deletions vendor/ansible/roles/dev/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# 'prebake-for-dev' tag in respective roles.

dependencies:
- { role: ceph-install, tags: 'prebake-for-dev' }
- { role: etcd }
- { role: docker }
- { role: swarm }
- { role: ucp }
- { role: contiv_cluster }
- { role: contiv_network }
- { role: contiv_storage }
11 changes: 0 additions & 11 deletions vendor/ansible/roles/dev/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,3 @@
- include: os_agnostic_tasks.yml
tags:
- prebake-for-dev

- include: ubuntu_tasks.yml
when: ansible_os_family == "Debian"
tags:
- prebake-for-dev


- include: redhat_tasks.yml
when: ansible_os_family == "RedHat"
tags:
- prebake-for-dev
27 changes: 4 additions & 23 deletions vendor/ansible/roles/dev/tasks/os_agnostic_tasks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
- name: download Golang v1.5.2
- name: download Golang v1.5.3
get_url:
validate_certs: "{{ validate_certs }}"
url: https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz
dest: /tmp/go1.5.2.linux-amd64.tar.gz
url: https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz
dest: /tmp/go1.5.3.linux-amd64.tar.gz
force: no

- name: install Golang
shell: tar xfvz /tmp/go1.5.2.linux-amd64.tar.gz
shell: tar xfvz /tmp/go1.5.3.linux-amd64.tar.gz
args:
chdir: /usr/local/
creates: /usr/local/go/bin/go
Expand All @@ -15,22 +15,3 @@
copy:
dest: /etc/profile.d/00golang.sh
content: "export PATH=/opt/golang/bin:/usr/local/go/bin:$PATH; export GOPATH=/opt/golang"

- name: check packer's version
shell: packer --version
register: packer_version
ignore_errors: yes

- name: download packer
get_url:
validate_certs: "{{ validate_certs }}"
url: https://releases.hashicorp.com/packer/0.8.6/packer_0.8.6_linux_amd64.zip
dest: /tmp/packer_0.8.6_linux_amd64.zip
force: no
when: packer_version.stdout != "0.8.6"

- name: install packer
shell: rm -f packer* && unzip /tmp/packer_0.8.6_linux_amd64.zip
args:
chdir: /usr/local/bin
when: packer_version.stdout != "0.8.6"
4 changes: 4 additions & 0 deletions vendor/ansible/roles/scheduler_stack/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# Role defaults for contiv_scheduler

scheduler_provider: "native-swarm" # Accepted values: native-swarm, ucp-swarm
7 changes: 7 additions & 0 deletions vendor/ansible/roles/scheduler_stack/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# This role contains tasks for configuring and starting the scheduler stacks
# like native-swarm, ucp-swarm, k8s, mesos etc

dependencies:
- { role: swarm, when: scheduler_provider == "native-swarm" }
- { role: ucp, when: scheduler_provider == "ucp-swarm" }
2 changes: 0 additions & 2 deletions vendor/ansible/roles/swarm/templates/swarm.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ fi
case $1 in
start)
echo starting swarm as {{ run_as }} on {{ node_name }}[{{ node_addr }}]
# XXX: we run etcd as master every where so it is fine to use the node-address for etcd, revisit this once we have
# etcd as master only on a subset of nodes
if [[ "{{ run_as }}" == "master" ]]; then
/usr/bin/swarm join --advertise={{ node_addr }}:{{ docker_api_port }} etcd://{{ node_addr }}:{{ etcd_client_port1 }} &
/usr/bin/swarm manage -H tcp://{{ node_addr }}:{{ swarm_api_port }} etcd://{{ node_addr }}:{{ etcd_client_port1 }}
Expand Down
17 changes: 17 additions & 0 deletions vendor/ansible/roles/test/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
# This role contains tasks for installing test environment packages

- include: os_agnostic_tasks.yml
tags:
- prebake-for-test

- include: ubuntu_tasks.yml
when: ansible_os_family == "Debian"
tags:
- prebake-for-test


- include: redhat_tasks.yml
when: ansible_os_family == "RedHat"
tags:
- prebake-for-test
18 changes: 18 additions & 0 deletions vendor/ansible/roles/test/tasks/os_agnostic_tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- name: check packer's version
shell: packer --version
register: packer_version
ignore_errors: yes

- name: download packer
get_url:
validate_certs: "{{ validate_certs }}"
url: https://releases.hashicorp.com/packer/0.8.6/packer_0.8.6_linux_amd64.zip
dest: /tmp/packer_0.8.6_linux_amd64.zip
force: no
when: packer_version.stdout != "0.8.6"

- name: install packer
shell: rm -f packer* && unzip /tmp/packer_0.8.6_linux_amd64.zip
args:
chdir: /usr/local/bin
when: packer_version.stdout != "0.8.6"
9 changes: 9 additions & 0 deletions vendor/ansible/roles/ucp/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Role defaults for ucp

ucp_version: "0.7.1"
ucp_local_dir: "fetch/ucp"
ucp_remote_dir: "/tmp"
ucp_instance_id_file: "ucp-instance-id"
ucp_fingerprint_file: "ucp-fingerprint"
ucp_fifo_file: "ucp-fifo"
8 changes: 8 additions & 0 deletions vendor/ansible/roles/ucp/files/ucp.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Ucp
After=auditd.service systemd-user-sessions.service time-sync.target docker.service

[Service]
ExecStart=/usr/bin/ucp.sh start
ExecStop=/usr/bin/ucp.sh stop
KillMode=control-group
12 changes: 12 additions & 0 deletions vendor/ansible/roles/ucp/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# This play contains tasks for cleaning up ucp

- name: stop ucp
service: name=ucp state=stopped

- name: cleanup ucp files from remote
file: name="{{ ucp_remote_dir }}/{{ item }}" state=absent
with_items:
- "{{ ucp_fingerprint_file }}"
- "{{ ucp_instance_id_file }}"
- "{{ ucp_fifo_file }}"
52 changes: 52 additions & 0 deletions vendor/ansible/roles/ucp/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# This role contains tasks for configuring and starting the swarm stack using ucp

- name: download and install ucp images
shell: >
docker run --rm -t \
--name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp \
images --image-version={{ ucp_version }}
- name: copy the ucp files to worker nodes
copy:
src: "{{ ucp_local_dir }}/{{ item }}"
dest: "{{ ucp_remote_dir }}/{{ item }}"
with_items:
- "{{ ucp_fingerprint_file }}"
- "{{ ucp_instance_id_file }}"
when: run_as == "worker"

- name: copy the ucp start/stop script
template: src=ucp.j2 dest=/usr/bin/ucp.sh mode=u=rwx,g=rx,o=rx

- name: copy systemd units for ucp
copy: src=ucp.service dest=/etc/systemd/system/ucp.service

- name: start ucp
service: name=ucp state=started

- name: create a local fetch directory if it doesn't exist
local_action: file path={{ ucp_local_dir }} state=directory
when: run_as == "master"

- name: wait for ucp files to be created, which ensures the service has started
wait_for:
path: "{{ ucp_remote_dir }}/{{ item }}"
state: present
with_items:
- "{{ ucp_fingerprint_file }}"
- "{{ ucp_instance_id_file }}"
when: run_as == "master"

- name: fetch the ucp files from master nodes
fetch:
src: "{{ ucp_remote_dir }}/{{ item }}"
dest: "{{ ucp_local_dir }}/{{ item }}"
flat: yes
fail_on_missing: yes
with_items:
- "{{ ucp_fingerprint_file }}"
- "{{ ucp_instance_id_file }}"
when: run_as == "master"
Loading

0 comments on commit acbe606

Please sign in to comment.