fetch openrc for functest 05/36905/10
authorwutianwei <wutianwei1@huawei.com>
Tue, 4 Jul 2017 09:46:39 +0000 (17:46 +0800)
committerwutianwei <wutianwei1@huawei.com>
Thu, 6 Jul 2017 03:08:59 +0000 (11:08 +0800)
We use openstack-ansible to deploy the openstack,
the position of openrc is different from the before.
change the apt source when use local apt repository

Change-Id: I1c5492b294a8645f452868c9cf2fec2e0802f823
Signed-off-by: wutianwei <wutianwei1@huawei.com>
17 files changed:
deploy/adapters/ansible/roles/config-compute/tasks/Ubuntu.yml
deploy/adapters/ansible/roles/config-compute/templates/sources.list.lab [new file with mode: 0644]
deploy/adapters/ansible/roles/config-compute/templates/sources.list.official [moved from deploy/adapters/ansible/roles/pre-openstack/templates/sources.list with 100% similarity]
deploy/adapters/ansible/roles/config-compute/vars/main.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/config-controller/tasks/Ubuntu.yml
deploy/adapters/ansible/roles/config-controller/templates/sources.list.lab [new file with mode: 0644]
deploy/adapters/ansible/roles/config-controller/templates/sources.list.official [new file with mode: 0644]
deploy/adapters/ansible/roles/config-controller/vars/main.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/files/fetch-openrc.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/files/http.yml
deploy/adapters/ansible/roles/config-osa/files/setup-ovs.yml
deploy/adapters/ansible/roles/config-osa/tasks/main.yml
deploy/adapters/ansible/roles/config-osa/vars/main.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/post-openstack/tasks/main.yml
deploy/adapters/ansible/roles/post-openstack/vars/main.yml
deploy/adapters/ansible/roles/pre-openstack/tasks/Ubuntu.yml
deploy/adapters/ansible/roles/setup-openvswitch/tasks/main.yml

index 886a407..6e6cae8 100644 (file)
 
 - meta: flush_handlers
 
+- name: check apt source
+  shell: "ping -c 2 {{ LOCAL_REPOSITORY_IP }} > /dev/null"
+  register: checkresult
+  ignore_errors: "true"
+
+- name: change sources list(apt)
+  template:
+    src: sources.list.lab
+    dest: /etc/apt/sources.list
+  when: checkresult.rc == 0
+
+- name: change sources list(apt)
+  template:
+    src: sources.list.official
+    dest: /etc/apt/sources.list
+  when: checkresult.rc != 0
+
 - name: Install apt packages
   apt:
     pkg: "nfs-kernel-server"
     state: "present"
+    update_cache: "yes"
 
 - name: make nfs dircetory
   file: "dest=/images mode=0777 state=directory"
diff --git a/deploy/adapters/ansible/roles/config-compute/templates/sources.list.lab b/deploy/adapters/ansible/roles/config-compute/templates/sources.list.lab
new file mode 100644 (file)
index 0000000..b1e00d0
--- /dev/null
@@ -0,0 +1,7 @@
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/  xenial main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
+
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
diff --git a/deploy/adapters/ansible/roles/config-compute/vars/main.yml b/deploy/adapters/ansible/roles/config-compute/vars/main.yml
new file mode 100644 (file)
index 0000000..783ea0d
--- /dev/null
@@ -0,0 +1,10 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+LOCAL_REPOSITORY_IP: "192.168.137.222"
index 53c2d50..c878ab7 100644 (file)
     dest: /etc/network/interfaces
   notify:
     - restart network service
+
+- name: check apt source
+  shell: "ping -c 2 {{LOCAL_REPOSITORY_IP}} > /dev/null"
+  register: checkresult
+  ignore_errors: "true"
+
+- name: change sources list(apt)
+  template:
+    src: sources.list.lab
+    dest: /etc/apt/sources.list
+  when: checkresult.rc == 0
+
+- name: change sources list(apt)
+  template:
+    src: sources.list.official
+    dest: /etc/apt/sources.list
+  when: checkresult.rc != 0
diff --git a/deploy/adapters/ansible/roles/config-controller/templates/sources.list.lab b/deploy/adapters/ansible/roles/config-controller/templates/sources.list.lab
new file mode 100644 (file)
index 0000000..b1e00d0
--- /dev/null
@@ -0,0 +1,7 @@
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/  xenial main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
+
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-security main restricted universe multiverse
+deb-src [ arch=amd64 ] http://{{LOCAL_REPOSITORY_IP}}/ubuntu/ xenial-updates main restricted universe multiverse
diff --git a/deploy/adapters/ansible/roles/config-controller/templates/sources.list.official b/deploy/adapters/ansible/roles/config-controller/templates/sources.list.official
new file mode 100644 (file)
index 0000000..799e4b5
--- /dev/null
@@ -0,0 +1,36 @@
+# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
+# newer versions of the distribution.
+
+deb http://archive.ubuntu.com/ubuntu/ xenial main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted
+
+## Major bug fix updates produced after the final release of the
+## distribution.
+deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
+
+## Uncomment the following two lines to add software from the 'universe'
+## repository.
+## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+## team. Also, please note that software in universe WILL NOT receive any
+## review or updates from the Ubuntu security team.
+deb http://archive.ubuntu.com/ubuntu/ xenial universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial universe
+deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates universe
+
+## N.B. software from this repository may not have been tested as
+## extensively as that contained in the main release, although it includes
+## newer versions of some applications which may provide useful features.
+## Also, please note that software in backports WILL NOT receive any review
+## or updates from the Ubuntu security team.
+# deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted
+# deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted
+
+deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted
+deb http://archive.ubuntu.com/ubuntu/ xenial-security universe
+deb-src http://archive.ubuntu.com/ubuntu/ xenial-security universe
+# deb http://archive.ubuntu.com/ubuntu/ xenial-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu/ xenial-security multiverse
+
diff --git a/deploy/adapters/ansible/roles/config-controller/vars/main.yml b/deploy/adapters/ansible/roles/config-controller/vars/main.yml
new file mode 100644 (file)
index 0000000..783ea0d
--- /dev/null
@@ -0,0 +1,10 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+LOCAL_REPOSITORY_IP: "192.168.137.222"
diff --git a/deploy/adapters/ansible/roles/config-osa/files/fetch-openrc.yml b/deploy/adapters/ansible/roles/config-osa/files/fetch-openrc.yml
new file mode 100644 (file)
index 0000000..1251cbf
--- /dev/null
@@ -0,0 +1,18 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+- name: Fetch openrc
+  hosts: utility_all[0]
+  max_fail_percentage: 20
+  user: root
+  tasks:
+    - fetch:
+        src: /root/openrc
+        dest: /opt/openrc
+        flat: "yes"
index 248fc06..d5c1e64 100644 (file)
@@ -1,3 +1,11 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
 ---
 - name: change https to http in haproxy configuratio
   hosts: network_hosts
index 57bc5ef..9f65cd5 100644 (file)
@@ -1,3 +1,11 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
 ---
 - name: Installation and setup of Neutron
   hosts: neutron_openvswitch_agent
index 8246d6e..aac1815 100644 (file)
     src: user_variables.yml.j2
     dest: /etc/openstack_deploy/user_variables.yml
 
+- name: check apt source
+  shell: "ping -c 2 {{ LOCAL_REPOSITORY_IP }} > /dev/null"
+  register: checkresult
+  ignore_errors: "true"
+
+- name: add mariadb local repository
+  blockinfile:
+    dest: /etc/openstack_deploy/user_variables.yml
+    block: |
+      galera_client_apt_repo_url: "http://192.168.137.222/mariadb"
+      galera_repo_url: "[ arch=amd64 ] http://192.168.137.222/mariadb"
+      uca_apt_repo_url: "[ arch=amd64 ] http://192.168.137.222/ubuntu-cloud"
+  when: checkresult.rc == 0
+
 - name: copy cinder.yml
   copy:
     src: cinder.yml
@@ -56,3 +70,8 @@
   copy:
     src: http.yml
     dest: /opt/openstack-ansible/playbooks/http.yml
+
+- name: copy fetch-openrc.yml
+  copy:
+    src: fetch-openrc.yml
+    dest: /opt/openstack-ansible/playbooks/fetch-openrc.yml
diff --git a/deploy/adapters/ansible/roles/config-osa/vars/main.yml b/deploy/adapters/ansible/roles/config-osa/vars/main.yml
new file mode 100644 (file)
index 0000000..783ea0d
--- /dev/null
@@ -0,0 +1,10 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+LOCAL_REPOSITORY_IP: "192.168.137.222"
index d5182c9..63df726 100644 (file)
   shell: "export ANSIBLE_LOG_PATH=/var/ansible/run/openstack_ocata-opnfv2/ansible.log; \
           cd /opt/openstack-ansible/playbooks; \
           openstack-ansible http.yml > /dev/null"
+
+- name: run ansible yml to fetch openrc
+  shell: "export ANSIBLE_LOG_PATH=/var/ansible/run/openstack_ocata-opnfv2/ansible.log; \
+          cd /opt/openstack-ansible/playbooks; \
+          openstack-ansible fetch-openrc.yml > /dev/null"
+
+- name: replace internalURL with publicURL in openrc
+  replace:
+    dest: /opt/openrc
+    regexp: "{{internal_vip}}"
+    replace: "{{ public_vip['ip']}}"
+
+- name: change the endpoint type
+  replace:
+    dest: /opt/openrc
+    regexp: "internalURL"
+    replace: "publicURL"
index d9c36d4..19d9e22 100644 (file)
@@ -7,6 +7,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
+internal_vip: "10.1.0.22"
 flavors:
   - id: 0
     name: m1.nano
index a0f7d01..5bb7748 100644 (file)
     - /tmp/ssh-keys-*
     - /root/.ssh/id_rsa.pub
 
-- name: change sourcesi(apt) list
-  template:
-    src: sources.list
-    dest: /etc/apt/sources.list
-
 - name: rm apt.conf
   file:
     path: /etc/apt/apt.conf
index f636ed1..a424f97 100644 (file)
@@ -12,5 +12,5 @@
           cd /opt/openstack-ansible/playbooks; \
           openstack-ansible setup-ovs.yml \
              | tee -a /var/log/osa/ovs.log > /dev/null"
-  when: NEUTRON_MECHANISM_DRIVERS[0] == "openvswitch" or \
+  when: NEUTRON_MECHANISM_DRIVERS[0] == "openvswitch" or
         NEUTRON_MECHANISM_DRIVERS[0] == "opendaylight"