daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jan 28th, 2016 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. - name: Creating Neutron database
  3.   command: docker exec -t kolla_ansible /usr/bin/ansible localhost
  4.     -m mysql_db
  5.     -a "login_host='{{ database_address }}'
  6.        login_user='{{ database_user }}'
  7.        login_password='{{ database_password }}'
  8.        name='{{ neutron_database_name }}'"
  9.   register: database
  10.   changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
  11.                    (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
  12.   failed_when: database.stdout.split()[2] != 'SUCCESS'
  13.   when: inventory_hostname == groups['neutron-server'][0]
  14.  
  15. - name: Reading json from variable
  16.   set_fact:
  17.     database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
  18.   when: inventory_hostname == groups['neutron-server'][0]
  19.  
  20. - name: Creating Neutron database user and setting permissions
  21.   command: docker exec -t kolla_ansible /usr/bin/ansible localhost
  22.     -m mysql_user
  23.     -a "login_host='{{ database_address }}'
  24.        login_user='{{ database_user }}'
  25.        login_password='{{ database_password }}'
  26.        name='{{ neutron_database_name }}'
  27.        password='{{ neutron_database_password }}'
  28.        host='%'
  29.        priv='{{ neutron_database_name }}.*:ALL'
  30.        append_privs='yes'"
  31.   register: database_user_create
  32.   changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
  33.                    (database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
  34.   failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
  35.   when: inventory_hostname == groups['neutron-server'][0] and database_created | bool
  36.  
  37. - name: Starting Neutron bootstrap container
  38.   docker:
  39.     tty: True
  40.     detach: False
  41.     net: host
  42.     pull: "{{ docker_pull_policy }}"
  43.     restart_policy: "no"
  44.     state: reloaded
  45.     registry: "{{ docker_registry }}"
  46.     username: "{{ docker_registry_username }}"
  47.     password: "{{ docker_registry_password }}"
  48.     insecure_registry: "{{ docker_insecure_registry }}"
  49.     name: bootstrap_neutron
  50.     image: "{{ neutron_server_image_full }}"
  51.     volumes: "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro"
  52.     env:
  53.       KOLLA_BOOTSTRAP:
  54.       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
  55.   when: inventory_hostname == groups['neutron-server'][0] and database_created | bool
  56.  
  57. # https://github.com/ansible/ansible-modules-core/pull/1031
  58. - name: Waiting for bootstrap container to exit
  59.   command: docker wait bootstrap_neutron
  60.   register: bootstrap_result
  61.   failed_when: bootstrap_result.stdout != "0"
  62.   when: inventory_hostname == groups['neutron-server'][0] and database_created | bool
  63.  
  64. - name: Cleaning up Neutron bootstrap container
  65.   docker:
  66.     name: bootstrap_neutron
  67.     image: "{{ neutron_server_image_full }}"
  68.     state: absent
  69.   when: inventory_hostname == groups['neutron-server'][0] and database_created | bool
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