SHARE
TWEET

Untitled

a guest Oct 4th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. # Copyright 2017 FUJITSU LIMITED
  3.  
  4. - name: Create OpenStack instance
  5.   hosts: openstack
  6.   gather_facts: false
  7.   tasks:
  8.   - name: Deploy an instance
  9.     os_server:
  10.       state: present
  11.       auth:
  12.         username: "{{ os_user_name }}"
  13.         password: "{{ os_password }}"
  14.         project_name: "{{ os_project_name }}"
  15.         auth_url: "{{ os_keystone_url }}"
  16.       name: "{{ os_instance_name }}"
  17.       image: "{{ os_image_id }}"
  18.       flavor: "{{ os_instance_flavor }}"
  19.       auto_floating_ip: "{{ os_instance_assign_floating_ip }}"
  20.       security_groups: "{{ os_instance_security_groups }}"
  21.       nics:
  22.         - net-id: "{{ os_network_id }}"
  23.       meta:
  24.         hostname: webserver.localdomain
  25.     register: nova
  26.  
  27.   - set_fact:
  28.       # All variables are left here, because of the compatibility reasons
  29.       monasca_host: "{{ nova.server.public_v4 }}"
  30.       node_1: "{{ nova.server.public_v4 }}"
  31.       node_1_admin_ip: "{{ nova.server.public_v4 }}"
  32.       node_1_public_ip: "127.0.0.1"
  33.       node_1_internal_ip: "127.0.0.1"
  34.  
  35.   - set_fact:
  36.       # Both variables are left here, because of the compatibility reasons
  37.       ssh_user_monasca: "{{ os_instance_user }}"
  38.       ssh_user_node_1: "{{ os_instance_user }}"
  39.  
  40.   - set_fact:
  41.       openstack_host: "{{ nova.server.public_v4 }}"
  42.  
  43.   - set_fact:
  44.       ssh_user_openstack: "{{ os_instance_user }}"
  45.  
  46.   - set_fact:
  47.       offline_resources_host: "{{ nova.server.public_v4 }}"
  48.  
  49.   - set_fact:
  50.       ssh_user_offline_host: "{{ os_instance_user }}"
  51.  
  52.   - set_fact:
  53.       rabbitmq_host: "{{ nova.server.public_v4 }}"
  54.  
  55.   - name: Add OpenStack instance to inventory
  56.     add_host:
  57.       name: openstack_vm
  58.       ansible_ssh_host: "{{ nova.server.public_v4 }}"
  59.       ansible_ssh_private_key_file: "{{ os_instance_user_key_path }}"
  60.       ansible_user: "{{ os_instance_user }}"
  61.  
  62.   - name: Create inventory file for monasca-installer
  63.     template:
  64.       src="{{ monasca_installer_path }}/templates/hosts-single.j2"
  65.       dest="{{ monasca_installer_path }}/hosts"
  66.     delegate_to: localhost
  67.  
  68.   - name: Update hosts file with keystone and horizon groups
  69.     blockinfile:
  70.       dest: "{{ monasca_installer_path }}/hosts"
  71.       block: |
  72.         [keystone_all]
  73.         keystone-node
  74.  
  75.         [horizon_all]
  76.         horizon-node
  77.  
  78.         [rabbitmq_all]
  79.         keystone-node
  80.  
  81.         [galera_all]
  82.         keystone-node
  83.     delegate_to: localhost
  84.  
  85.   - name: Insert passwords to credentials.yml
  86.     replace:
  87.       dest: "{{ monasca_installer_path }}/credentials.yml"
  88.       regexp: '(.+_password:)$'
  89.       replace: '\1 admin'
  90.     delegate_to: localhost
  91.  
  92.   - name: Wait for SSH port on the VM to open
  93.     local_action:
  94.       module: wait_for
  95.       host: "{{ nova.server.public_v4 }}"
  96.       port: 22
  97.       delay: 30
  98.       timeout: 300
  99.       state: started
  100.  
  101. - name: Initial VM provisioning
  102.   hosts: openstack_vm
  103.   become: yes
  104.   tasks:
  105.   - name: Install rsync on OpenStack VM
  106.     yum:
  107.       name: rsync
  108.       state: present
  109.  
  110.   - name: Add VM hostname to /etc/hosts [needed by storm]
  111.     lineinfile:
  112.       dest: /etc/hosts
  113.       regexp: '^127\.0\.0\.1'
  114.       line: "127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 {{ hostvars.openstack.nova.server.name }} {{ hostvars.openstack.nova.server.name }}.novalocal"
  115.       owner: root
  116.       group: root
  117.       mode: 0644
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top