aboutsummaryrefslogtreecommitdiffstats
path: root/opt/infra
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-01-08 09:48:31 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-01-11 15:14:16 +0800
commit23b627df622eeafafa215ce19764310c1d55dd55 (patch)
treed92c4c9b8a50a03461a40d2a2aba67bc7312041a /opt/infra
parent23f48e46a46976ae6f6d97aea11440e6a8b63121 (diff)
Reorganize the project folders
Code from Brahmaputra is no longer maintained, including: - docker - playbooks - scripts - utils They are moved to legacy folder to avoid unnecessary confusion to new developers. Change-Id: Ia50383ca5c3bd82571eb7b2184e7f83e264ff8a7 Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'opt/infra')
-rw-r--r--opt/infra/ansible.cfg3
-rw-r--r--opt/infra/inventory4
-rw-r--r--opt/infra/roles/docker/handlers/main.yml4
-rw-r--r--opt/infra/roles/docker/tasks/main.yml41
-rw-r--r--opt/infra/roles/elk/tasks/main.yml22
-rw-r--r--opt/infra/roles/mongo/tasks/main.yml10
-rw-r--r--opt/infra/roles/nginx/defaults/main.yml10
-rw-r--r--opt/infra/roles/nginx/handlers/main.yml4
-rw-r--r--opt/infra/roles/nginx/tasks/main.yml13
-rw-r--r--opt/infra/roles/nginx/templates/elk.conf.j214
-rw-r--r--opt/infra/roles/nginx/templates/qtip.conf.j217
-rw-r--r--opt/infra/roles/nginx/templates/testapi.conf.j217
-rw-r--r--opt/infra/roles/qtip/files/run_qtip_server.sh4
-rw-r--r--opt/infra/roles/qtip/tasks/main.yml5
-rw-r--r--opt/infra/roles/testapi/files/run_testapi.sh4
-rw-r--r--opt/infra/roles/testapi/tasks/main.yml4
-rw-r--r--opt/infra/roles/user/defaults/main.yml7
-rw-r--r--opt/infra/roles/user/files/akhil.authorized_keys1
-rw-r--r--opt/infra/roles/user/files/serena.authorized_keys1
-rw-r--r--opt/infra/roles/user/files/sudoers.d-qtip2
-rw-r--r--opt/infra/roles/user/files/taseer.authorized_keys1
-rw-r--r--opt/infra/roles/user/files/yujunz.authorized_keys3
-rw-r--r--opt/infra/roles/user/files/zhifeng.authorized_keys1
-rw-r--r--opt/infra/roles/user/tasks/main.yml35
-rw-r--r--opt/infra/test.yml10
25 files changed, 237 insertions, 0 deletions
diff --git a/opt/infra/ansible.cfg b/opt/infra/ansible.cfg
new file mode 100644
index 00000000..93022c4e
--- /dev/null
+++ b/opt/infra/ansible.cfg
@@ -0,0 +1,3 @@
+[defaults]
+hostfile = inventory
+host_key_checking = False \ No newline at end of file
diff --git a/opt/infra/inventory b/opt/infra/inventory
new file mode 100644
index 00000000..1ba1dc45
--- /dev/null
+++ b/opt/infra/inventory
@@ -0,0 +1,4 @@
+table ansible_host=table.qtip.io # 1vCPU/1024MB/100Mbps/40GB (Aliyun Hongkong B)
+
+[testing]
+table
diff --git a/opt/infra/roles/docker/handlers/main.yml b/opt/infra/roles/docker/handlers/main.yml
new file mode 100644
index 00000000..985f8d41
--- /dev/null
+++ b/opt/infra/roles/docker/handlers/main.yml
@@ -0,0 +1,4 @@
+---
+- name: starting docker service
+ become: true
+ service: name=docker state=started
diff --git a/opt/infra/roles/docker/tasks/main.yml b/opt/infra/roles/docker/tasks/main.yml
new file mode 100644
index 00000000..1cf3bea0
--- /dev/null
+++ b/opt/infra/roles/docker/tasks/main.yml
@@ -0,0 +1,41 @@
+- name: adding keys
+ become: true
+ apt_key: keyserver=hkp://p80.pool.sks-keyservers.net id=0X58118E89F3A912897C070ADBF76221572C52609D
+
+- name: adding entry for ubuntu
+ become: true
+ apt_repository: repo='deb https://apt.dockerproject.org/repo ubuntu-xenial main' state=present filename='docker'
+ when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "16.04"
+
+- name: installing from docker repo
+ become: true
+ shell: apt-cache policy docker-engine
+ when: ansible_distribution == "Ubuntu" and ansible_distribution_version== "16.04"
+
+- name: adding entry for ubuntu
+ become: true
+ apt_repository: repo='deb https://apt.dockerproject.org/repo ubuntu-trusty main' state=present filename='docker'
+ when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04"
+
+- name: updating
+ become: true
+ apt: update_cache=yes
+
+- name: installing docker engine
+ become: true
+ apt: name=docker-engine
+ notify:
+ - starting docker service
+
+- name: install pip
+ become: true
+ apt: name={{item}} state=installed
+ with_items:
+ - python-dev
+ - python-pip
+
+- name: install docker-py
+ become: true
+ pip:
+ name: docker-py
+ version: 1.7.0
diff --git a/opt/infra/roles/elk/tasks/main.yml b/opt/infra/roles/elk/tasks/main.yml
new file mode 100644
index 00000000..ed987f1a
--- /dev/null
+++ b/opt/infra/roles/elk/tasks/main.yml
@@ -0,0 +1,22 @@
+---
+- name: pulling elasticsearch and kibana
+ become: true
+ docker_image: name={{ item }} state=present
+ with_items:
+ - elasticsearch
+ - kibana
+
+- name: setting up elasticsearch
+ become: true
+ docker_container:
+ name: esearch
+ image: elasticsearch
+ published_ports: 9200:9200
+
+- name: setting up kibana
+ become: true
+ docker_container:
+ name: kibana
+ image: kibana
+ published_ports: 5601:5601
+ links: esearch:elasticsearch
diff --git a/opt/infra/roles/mongo/tasks/main.yml b/opt/infra/roles/mongo/tasks/main.yml
new file mode 100644
index 00000000..81fb49b5
--- /dev/null
+++ b/opt/infra/roles/mongo/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+- name: pulling mongo
+ become: true
+ docker_image: name=mongo:3.2.1 state=present
+
+- name: setting up mongo
+ become: true
+ docker_container:
+ name: mongo
+ image: mongo:3.2.1
diff --git a/opt/infra/roles/nginx/defaults/main.yml b/opt/infra/roles/nginx/defaults/main.yml
new file mode 100644
index 00000000..cdd1d773
--- /dev/null
+++ b/opt/infra/roles/nginx/defaults/main.yml
@@ -0,0 +1,10 @@
+---
+services:
+ - { name: kibana, upstream: 'http://127.0.0.1:5601' }
+ - { name: elastic, upstream: 'http://127.0.0.1:9200' }
+
+qtip_services:
+ - { name: restful_api, upstream: 'http://127.0.0.1:5000' }
+
+testapi_services:
+ - { name: testapi, upstream: 'http://127.0.0.1:8000' }
diff --git a/opt/infra/roles/nginx/handlers/main.yml b/opt/infra/roles/nginx/handlers/main.yml
new file mode 100644
index 00000000..35585363
--- /dev/null
+++ b/opt/infra/roles/nginx/handlers/main.yml
@@ -0,0 +1,4 @@
+---
+- name: restart nginx
+ become: true
+ service: name=nginx state=restarted
diff --git a/opt/infra/roles/nginx/tasks/main.yml b/opt/infra/roles/nginx/tasks/main.yml
new file mode 100644
index 00000000..5c78166c
--- /dev/null
+++ b/opt/infra/roles/nginx/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+- name: nginx is installed
+ become: true
+ package: name=nginx state=present
+- name: qtip server configuration is generated
+ become: true
+ template: src={{ item }}.conf.j2 dest=/etc/nginx/sites-enabled/{{ item }}.conf
+ with_items:
+ - elk
+ - qtip
+ - testapi
+ notify:
+ - restart nginx
diff --git a/opt/infra/roles/nginx/templates/elk.conf.j2 b/opt/infra/roles/nginx/templates/elk.conf.j2
new file mode 100644
index 00000000..271690e0
--- /dev/null
+++ b/opt/infra/roles/nginx/templates/elk.conf.j2
@@ -0,0 +1,14 @@
+# {{ ansible_managed }}
+
+# servers
+#
+{% for service in services %}
+server {
+ listen 80;
+ listen 443 ssl;
+ server_name {{ service.name }}.qtip.openzero.net;
+ location / {
+ proxy_pass {{ service.upstream }};
+ }
+}
+{% endfor %}
diff --git a/opt/infra/roles/nginx/templates/qtip.conf.j2 b/opt/infra/roles/nginx/templates/qtip.conf.j2
new file mode 100644
index 00000000..3a15c6ba
--- /dev/null
+++ b/opt/infra/roles/nginx/templates/qtip.conf.j2
@@ -0,0 +1,17 @@
+# {{ ansible_managed }}
+
+# servers
+#
+{% for service in qtip_services %}
+server {
+ listen 80;
+ listen 443 ssl;
+ server_name {{ service.name }}.qtip.openzero.net;
+ location / {
+ proxy_pass {{ service.upstream }};
+ sub_filter {{ service.upstream }} 'http://{{ service.name }}.qtip.openzero.net';
+ sub_filter_once off;
+ sub_filter_types text/html application/json;
+ }
+}
+{% endfor %}
diff --git a/opt/infra/roles/nginx/templates/testapi.conf.j2 b/opt/infra/roles/nginx/templates/testapi.conf.j2
new file mode 100644
index 00000000..6a4d388b
--- /dev/null
+++ b/opt/infra/roles/nginx/templates/testapi.conf.j2
@@ -0,0 +1,17 @@
+# {{ ansible_managed }}
+
+# servers
+#
+{% for service in testapi_services %}
+server {
+ listen 80;
+ listen 443 ssl;
+ server_name {{ service.name }}.qtip.openzero.net;
+ location / {
+ proxy_pass {{ service.upstream }};
+ sub_filter {{ service.upstream }} 'http://{{ service.name }}.qtip.openzero.net';
+ sub_filter_once off;
+ sub_filter_types text/html application/json;
+ }
+}
+{% endfor %}
diff --git a/opt/infra/roles/qtip/files/run_qtip_server.sh b/opt/infra/roles/qtip/files/run_qtip_server.sh
new file mode 100644
index 00000000..0f5cafea
--- /dev/null
+++ b/opt/infra/roles/qtip/files/run_qtip_server.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+envs="INSTALLER_TYPE=fuel -e INSTALLER_IP=10.20.0.2 -e NODE_NAME=zte-pod1"
+docker run --name qtip -id -e $envs -p 5000:5000 opnfv/qtip
diff --git a/opt/infra/roles/qtip/tasks/main.yml b/opt/infra/roles/qtip/tasks/main.yml
new file mode 100644
index 00000000..b8292791
--- /dev/null
+++ b/opt/infra/roles/qtip/tasks/main.yml
@@ -0,0 +1,5 @@
+---
+# TODO:change the script to docker_container.
+- name: setting up qtip
+ become: true
+ script: ../files/run_qtip_server.sh
diff --git a/opt/infra/roles/testapi/files/run_testapi.sh b/opt/infra/roles/testapi/files/run_testapi.sh
new file mode 100644
index 00000000..f9ba8387
--- /dev/null
+++ b/opt/infra/roles/testapi/files/run_testapi.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+envs="mongodb_url=mongodb://mongo:27017/ -e api_port=8000 -e swagger_url=http://testapi.qtip.openzero.net"
+docker run --name testapi --link mongo:mongo -p 8000:8000 -e $envs -d opnfv/testapi
diff --git a/opt/infra/roles/testapi/tasks/main.yml b/opt/infra/roles/testapi/tasks/main.yml
new file mode 100644
index 00000000..8ca91396
--- /dev/null
+++ b/opt/infra/roles/testapi/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- name: setting up testapi
+ become: true
+ script: ../files/run_testapi.sh
diff --git a/opt/infra/roles/user/defaults/main.yml b/opt/infra/roles/user/defaults/main.yml
new file mode 100644
index 00000000..ef496dd4
--- /dev/null
+++ b/opt/infra/roles/user/defaults/main.yml
@@ -0,0 +1,7 @@
+---
+users:
+ - { name: yujunz, comment: "Yujun Zhang <zhang.yujunz@zte.com.cn>" }
+ - { name: taseer, comment: "Taseer Ahmed <taseer94@gmail.com>" }
+ - { name: serena, comment: "Serena Feng <feng.xiaowei@zte.com.cn>" }
+ - { name: zhifeng, comment: "Zhifeng Jiang<jiang.zhifeng@zte.com.cn>" }
+ - { name: akhil, comment: "Akhil Batra<akhil.batra@research.iiit.ac.in"}
diff --git a/opt/infra/roles/user/files/akhil.authorized_keys b/opt/infra/roles/user/files/akhil.authorized_keys
new file mode 100644
index 00000000..43942621
--- /dev/null
+++ b/opt/infra/roles/user/files/akhil.authorized_keys
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ2zxPZ6gu19QhXlzCdZQjiRIXnzE0Tp2+7LL5hBbl39+dohPwKlSvXzlI9n3MpeDUBkEwUzcS/P4McbTYOU74nOb5vBoNhgayZIebG3gM5cgLwRVD219oOT6mBGNSgfuc54KvmDgIOX4p8o8TLFq+0Qv4YQXcj3uprAR3p5e9NDAfKX8k27M4Ba9Goqorda/0CguAT6b+MdWen554N9PJLWQwtN1Nm4CMf7R9QcDOQEwOXhoZoN+/xmgqQummoo+17IYaAslQhb3Cx16hy2JA8QhZa6k+KnAUvh9GHxGSZpex7w6jyDez5KngROQvIiLfjYkqlgD3O8CDfhrjccZ5 akhil.batra@research.iiit.ac.in
diff --git a/opt/infra/roles/user/files/serena.authorized_keys b/opt/infra/roles/user/files/serena.authorized_keys
new file mode 100644
index 00000000..5cdbfe00
--- /dev/null
+++ b/opt/infra/roles/user/files/serena.authorized_keys
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYlLrMOPxwLNQvLpxXVLYXQCxNkaKfVWt7u9k+6T0SU7VNuT8e1VoTk6b/iVWyXQ4j1hW4sNroTucqZjl+8V2z2nYgpEMIy6jBuehlKP2LJ9v/p98/OBVVxgEnRJGzFYIeO/GKBLMaUu43OkCO2Ef67qKeISeNP5/ewUR12YCUHQg5GkGYnDL3fFd7SiVDkYPEXQvHfi85beGOuPwDTjbKoKbF9WATIIzJSPUmslGjFRpKqM8AQLGWEyTeklU7H4ddRqaKxe6DGbpTLJM2rCMF8W91097nmiOKEnuxi6vJKTmyX81BZXi48ugCRh3942ONYRH8W7dBegrvRY3kyAtH root@gsmdev-VirtualBox
diff --git a/opt/infra/roles/user/files/sudoers.d-qtip b/opt/infra/roles/user/files/sudoers.d-qtip
new file mode 100644
index 00000000..e96d278a
--- /dev/null
+++ b/opt/infra/roles/user/files/sudoers.d-qtip
@@ -0,0 +1,2 @@
+# Group rules for qtip-contributors
+%qtip ALL=(ALL) NOPASSWD:ALL
diff --git a/opt/infra/roles/user/files/taseer.authorized_keys b/opt/infra/roles/user/files/taseer.authorized_keys
new file mode 100644
index 00000000..2efb95e8
--- /dev/null
+++ b/opt/infra/roles/user/files/taseer.authorized_keys
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCxCG9Z+8rBLQiJ9yt+RzRkAZZQIlou83e899Kkuf/UgXd+1TUgIu4AJUDvayrorTxk2kw7ra+DoysEa2NBkLL6FNnG+NpYV+XTaG+Z3tvp4l62ROV+5+O4soiWtBroRghQPDkrpiTQuFJ7/BKQt9bKZYPb3t2bxCLeFVWtUzCpFDIj6wDPGwDeTLnLMPtQNQtIlgPV+XGAet17rNSrm7EcDzqdDQcdZFmfeH5YvBsY9ZO+qwcbelEpMBWPsyEMU6OgwTqUj7mm3o+Quew35y13Zrhf+GAx5ZMXho/Cpjp1TzognDkwAFpFzZG7zWSNexXrD15Wzgyae2cl/vD75I7 taseer@123.org \ No newline at end of file
diff --git a/opt/infra/roles/user/files/yujunz.authorized_keys b/opt/infra/roles/user/files/yujunz.authorized_keys
new file mode 100644
index 00000000..83ed540d
--- /dev/null
+++ b/opt/infra/roles/user/files/yujunz.authorized_keys
@@ -0,0 +1,3 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0o+WARhbI5DeZK9eiZKVprY3oQ910npo/EPFI9prfpN7zeF0UA4TwT9rqsrwFgRQeJkKvbDTOPt5Ox9vLIEnxT4PdirvrYNxtyJHHfbL4ZxKemYhBi2BA6CAbI3f9CR+dtbfOBxtTpXAj1Y5oA9y59o1hqHpuVmM8dBpcQt/ELdYCHZ0khxft5WaSOURsslTZN18bikVX9WHlKflVyRA8efxqzTZ4w5ufHl1Fv9i/G0u7iGbUtvlI8X7+Z+ePuysZhHKErQSGfv2NybDi+r8xM5hL2LYXxjAu0PV58olUl1SX40OY9yA2Yx+PVzIGhv6EQ8snUFnsoMy0ZIbQ+ysB yujunz@silver.mbp
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDs9VhmmGg0c7FTLMtoZlPue4N1DdSCh6r6YssmEY3e1GHPXJTGGTX7QKXEBlWd7EXq+uedwN+lU9C/FClwneP0M+4vprgqdmUcmlCoSI/RffQAymcuGbxvfptNcLpBApHn4C+e93H/5ryaypaG+6n8WtbDZDtvWgn2ZJY6hDdJSw6Y++C+zDI0QliTsrCHmnGnYcRuDWUNgaiERvW3cvpeF5duFJcDZ0NtMl2UjeGMYL0JU6YfIOIeeFwD0Su86Nf3RtoKF+RzO4LcrGLvywzM7C/iCncIdj6GZjpVBYnB5U6YUh8VqLjHVHjmjTpAjmsWcc8NnwNG9rHDbG6nrGWd yujunz@silver
+
diff --git a/opt/infra/roles/user/files/zhifeng.authorized_keys b/opt/infra/roles/user/files/zhifeng.authorized_keys
new file mode 100644
index 00000000..195cfdca
--- /dev/null
+++ b/opt/infra/roles/user/files/zhifeng.authorized_keys
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuck9a5uUXLtzlTaCYhwcLDffFH8o5ldhU4iKr0D4KaXlFfUsKD7VyHN+Zck3HBWTB4U7X9FEeFINtp2v2aoY8n74TS4LUGT8yqRYLyvsh2LgrhE4ouRvYgWlrZGice2x6ZZrcGM4uoGTC/lUHEvMDGDkDxUCfhxlFWcrplCUMcgd1V/5U14s0ufDgLGyEhXWWXFW4pNoqKBEGZNChBSvnq+NvOD7I4jgStUm9REooOp/VPpubH/6mSvDSTokCvrgWSCaNpcDqLCUjhwpoT/D1oFzEd4jBfPSV3jva+eAKPE2r/dnudQR5NR8T/eUz25YRGeJfrjDP6cMgXJoG43IXQ== root@fuel.domain.tld
diff --git a/opt/infra/roles/user/tasks/main.yml b/opt/infra/roles/user/tasks/main.yml
new file mode 100644
index 00000000..b1b5be9b
--- /dev/null
+++ b/opt/infra/roles/user/tasks/main.yml
@@ -0,0 +1,35 @@
+- name: add group qtip
+ become: true
+ group: name=qtip state=present
+- name: add qtip to sudoers without password
+ become: true
+ file:
+ src: sudoers.d-qtip
+ dest: /etc/sudoers.d/50-qtip
+ mode: 0440
+- name: add users for ssh access
+ become: true
+ user:
+ name: "{{ item.name }}"
+ comment: "{{ item.comment }}"
+ groups: "qtip"
+ append: yes
+ with_items: "{{ users }}"
+- name: create .ssh directory
+ become: true
+ file:
+ path: "/home/{{ item.name }}/.ssh"
+ state: directory
+ owner: "{{ item.name }}"
+ group: "{{ item.name }}"
+ mode: 0700
+ with_items: "{{ users }}"
+- name: authorize public key
+ become: true
+ copy:
+ src: "{{ item.name }}.authorized_keys"
+ dest: "/home/{{ item.name }}/.ssh/authorized_keys"
+ owner: "{{ item.name }}"
+ group: "{{ item.name }}"
+ mode: 0600
+ with_items: "{{ users }}"
diff --git a/opt/infra/test.yml b/opt/infra/test.yml
new file mode 100644
index 00000000..ee3ded13
--- /dev/null
+++ b/opt/infra/test.yml
@@ -0,0 +1,10 @@
+---
+- hosts: testing
+ roles:
+ - user
+ - docker
+ - elk
+ - mongo
+ - nginx
+ - qtip
+ - testapi