aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/ubuntu_server_cloudimg_modify.yml
blob: 90235cc814b8af10b5317b4d4dfe9089389341c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) 2017 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- hosts: chroot_image
  connection: chroot
  vars:
    # used to install the tools
    clone_dir: /tmp/yardstick-clone

  pre_tasks:
    - debug: msg="chrooted in {{ inventory_hostname }}"

  roles:
    - reset_resolv_conf
    - add_custom_repos
    - modify_cloud_config
    - role: set_package_installer_proxy
      when: proxy_env is defined and proxy_env
    - download_l2fwd
    - install_image_dependencies
    - download_unixbench
    - install_unixbench
    - download_ramspeed
    - install_ramspeed
    - download_cachestat
    # there is no install for cachestat
#    - install_cachestat
066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
##############################################################################
# Copyright (c) 2016 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: get http server
  shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
  register: http_server

- name: creat tacker_home, tacker_client_home, tacker_horizon_home
  shell: >
    mkdir -p /opt/tacker
    mkdir -p /opt/tacker_client
    mkdir -p /opt/tacker_horizon

- name: download tacker package
  get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/tacker/{{ tacker_pkg_name }}"  dest=/opt/{{ tacker_pkg_name }}

- name: download tacker_client package
  get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/tacker/{{ tacker_client_pkg_name }}"  dest=/opt/{{ tacker_client_pkg_name }}

- name: download tacker_horizon package
  get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/tacker/{{ tacker_horizon_pkg_name }}"  dest=/opt/{{ tacker_horizon_pkg_name }}

- name: extract tacker package
  command: su -s /bin/sh -c "tar xzf /opt/{{ tacker_pkg_name }} -C {{ tacker_home }} --strip-components 1 --no-overwrite-dir -k --skip-old-files"

- name: extract tacker_client package
  command: su -s /bin/sh -c "tar xzf /opt/{{ tacker_client_pkg_name }} -C {{ tacker_client_home }} --strip-components 1 --no-overwrite-dir -k --skip-old-files"

- name: extract tacker_horizon package
  command: su -s /bin/sh -c "tar xzf /opt/{{ tacker_horizon_pkg_name }} -C {{ tacker_horizon_home }} --strip-components 1 --no-overwrite-dir -k --skip-old-files"

- name: edit ml2_conf.ini
  shell: crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security;

- name: Restart neutron-server
  service: name=neutron-server state=restarted

- name: "create haproxy configuration for tacker"
  template:
    src: "haproxy-tacker-cfg.j2"
    dest: "/tmp/haproxy-tacker.cfg"

- name: get the current haproxy configuration
  shell: cat /etc/haproxy/haproxy.cfg
  register: ha_cfg

- name: "combination of the haproxy configuration"
  shell: "cat /tmp/haproxy-tacker.cfg >> /etc/haproxy/haproxy.cfg"
  when: ha_cfg.stdout.find('8888') == -1

- name: "delete temporary configuration file"
  file:
    dest: "/tmp/haproxy-tacker.cfg"
    state: "absent"

- name: "restart haproxy"
  service:
    name: "haproxy"
    state: "restarted"

- name: drop and recreate tacker database
  shell: mysql -e "drop database if exists tacker;";
         mysql -e "create database tacker character set utf8;";
         mysql -e "grant all on tacker.* to 'tacker'@'%' identified by 'TACKER_DBPASS';";
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: get the openstack user info
  shell: . /opt/admin-openrc.sh; openstack user list
  register: user_info

- name: get the openstack service info
  shell: . /opt/admin-openrc.sh; openstack service list
  register: service_info

- name: get the openstack endpoint info
  shell: . /opt/admin-openrc.sh; openstack endpoint list
  register: endpoint_info

- name: delete the existed tacker endpoint
  shell: . /opt/admin-openrc.sh; openstack endpoint delete $(openstack endpoint list | grep tacker | awk '{print $2}')
  when: endpoint_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0]

- name: delete the existed tacker service
  shell: . /opt/admin-openrc.sh; openstack service delete tacker
  when: service_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0]

- name: delete the existed tacker user
  shell: . /opt/admin-openrc.sh; openstack user delete tacker
  when: user_info.stdout.find('tacker') != -1 and inventory_hostname == haproxy_hosts.keys()[0]

- name: create tacker user with admin privileges
  shell: . /opt/admin-openrc.sh; openstack user create --password console tacker; openstack role add --project service --user tacker admin;
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: creat tacker service
  shell: >
    . /opt/admin-openrc.sh; openstack service create --name tacker --description "Tacker Project" nfv-orchestration
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: provide an endpoint to tacker service
  shell: >
    . /opt/admin-openrc.sh; openstack endpoint create --region RegionOne \
        --publicurl 'http://{{ public_vip.ip }}:8888/' \
        --adminurl 'http://{{ internal_vip.ip }}:8888/' \
        --internalurl 'http://{{ internal_vip.ip }}:8888/' tacker
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: install pip package
  pip: name=Babel state=present version=2.3.4

- name: install pip packages
  shell: >
    pip install tosca-parser heat-translator oslosphinx;

- name: install tacker
  shell: >
    . /opt/admin-openrc.sh; cd {{ tacker_home }}; python setup.py install

- name: create 'tacker' directory in '/var/cache', set ownership and permissions
  shell: >
    mkdir -p /var/cache/tacker
#   sudo chown <LOGIN_USER>:root /var/cache/tacker
#    chmod 700 /var/cache/tacker

- name: create 'tacker' directory in '/var/log'
  shell: mkdir -p /var/log/tacker

- name: copy tacker configs
  template: src={{ item.src }} dest=/opt/os_templates
  with_items: "{{ tacker_configs_templates }}"

- name: edit tacker configuration file
  shell: crudini --merge /usr/local/etc/tacker/tacker.conf < /opt/os_templates/tacker.j2

- name: populate tacker database
  shell: >
    . /opt/admin-openrc.sh; /usr/local/bin/tacker-db-manage --config-file /usr/local/etc/tacker/tacker.conf upgrade head
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: install tacker client
  shell: >
    . /opt/admin-openrc.sh; cd {{ tacker_client_home }}; python setup.py install

- name: install tacker horizon
  shell: >
    . /opt/admin-openrc.sh; cd {{ tacker_horizon_home }}; python setup.py install

- name: enable tacker horizon in dashboard
  shell: >
    cp {{ tacker_horizon_home }}/openstack_dashboard_extensions/* /usr/share/openstack-dashboard/openstack_dashboard/enabled/

- name: restart apache server
  shell: service apache2 restart

- name: create tacker service
  copy: src=tacker.conf dest=/etc/init

- name: create tacker service work dir 
  file: path=/var/lib/tacker state=directory

- name: link the tacker service 
  file: 
    src: /etc/init/tacker.conf
    dest: /etc/init.d/tacker
    state: link

- name: start tacker service
  shell: service tacker start

- name: create tackerc file
  template: src=tackerc.sh dest=/opt/tackerc.sh mode=777

- name: get the nfv_user info
  shell: . /opt/tackerc.sh; openstack user list
  register: nfvuser_info

- name: delete the existed nfv user
  shell: . /opt/tackerc.sh; openstack user delete nfv_user
  when: nfvuser_info.stdout.find('nfv') != -1 and inventory_hostname == haproxy_hosts.keys()[0]

- name: get the openstack project info
  shell: . /opt/tackerc.sh; openstack project list
  register: nfvproject_info

- name: delete the existed nfv project
  shell: . /opt/tackerc.sh; openstack project delete $(openstack project list | grep nfv | awk '{print $2}')
  when: nfvproject_info.stdout.find('nfv') != -1 and inventory_hostname == haproxy_hosts.keys()[0]

- name: create an nfv project
  shell: . /opt/tackerc.sh; openstack project create --description "NFV Project" nfv
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: create nfv user with admin privileges
  shell: . /opt/tackerc.sh; openstack user create --password console nfv_user; openstack role add --project nfv --user nfv_user admin;
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: create config.yml
  template: src=config.yaml dest=/opt/config.yaml

- name: check if tacker running
  shell: . /opt/tackerc.sh; while (!(tacker ext-list)); do sleep 30; done

- name: register VIM to tacker
  shell: . /opt/tackerc.sh; tacker vim-register --config-file /opt/config.yaml --description "OpenStack" --name VIM0
  when: inventory_hostname == haproxy_hosts.keys()[0]

- name: restart tacker service
  shell: service tacker stop; service tacker start