diff --git a/horizon.yml b/horizon.yml index 7a3b20a..6bd1997 100644 --- a/horizon.yml +++ b/horizon.yml @@ -1,4 +1,8 @@ --- +- hosts: all + name: Dummy to gather facts + tasks: [] + - hosts: horizon become: True roles: diff --git a/hosts b/hosts index bb0e3dc..268bb96 100644 --- a/hosts +++ b/hosts @@ -11,7 +11,7 @@ openstack01-node01 openstack01-node02 [horizon] -kolla2 +openstack01-node03 [rabbitmq] openstack01-node01 @@ -39,3 +39,6 @@ run_options="-e CASSANDRA_SEEDS=172.23.41.1" [nova-controller] openstack01-node01 + +[nova-compute] +openstack01-node04 diff --git a/nova-compute.yml b/nova-compute.yml new file mode 100644 index 0000000..69487e2 --- /dev/null +++ b/nova-compute.yml @@ -0,0 +1,9 @@ +--- +- hosts: all + name: Dummy to gather facts + tasks: [] + +- hosts: nova-compute + become: True + roles: + - nova-compute diff --git a/roles/horizon/templates/horizon.service b/roles/horizon/templates/horizon.service index cd554c6..014aab5 100644 --- a/roles/horizon/templates/horizon.service +++ b/roles/horizon/templates/horizon.service @@ -8,8 +8,10 @@ TimeoutStartSec=0 Restart=always ExecStartPre=-/usr/bin/docker rm -f %n ExecStart=/usr/bin/docker run --name %n \ - -e "MEMCACHED_SERVER={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \ - -e "OPENSTACK_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "MEMCACHED_SERVER={{ hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \ + --add-host=nova-controller:{{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }} \ + --add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }} \ -p 80:80 \ hpc/horizon diff --git a/roles/nova-compute/tasks/main.yml b/roles/nova-compute/tasks/main.yml new file mode 100644 index 0000000..634c66e --- /dev/null +++ b/roles/nova-compute/tasks/main.yml @@ -0,0 +1,24 @@ +# Build and install a docker image for nova-controller. +--- +- name: install service file. + template: + src: templates/nova-compute.service + dest: /etc/systemd/system/nova-compute.service + mode: 644 + owner: root + group: root + +- command: systemctl daemon-reload + +- apt: + name: '{{ item }}' + with_items: + - kvm + - libvirt0 + - libvirt-bin + - qemu + +- name: make sure service is started + systemd: + name: nova-compute.service + state: restarted diff --git a/roles/nova-compute/templates/nova-compute.service b/roles/nova-compute/templates/nova-compute.service new file mode 100644 index 0000000..abd7086 --- /dev/null +++ b/roles/nova-compute/templates/nova-compute.service @@ -0,0 +1,35 @@ +[Unit] +Description=Openstack nova-compute Container +After=docker.service +Requires=docker.service + +[Service] +TimeoutStartSec=0 +Restart=always +ExecStartPre=-/usr/bin/docker rm -f %n +ExecStart=/usr/bin/docker run --name %n \ + -e "MY_IP={{ hostvars[groups['nova-compute'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "NOVA_USER=nova" \ + -e "NOVA_COMPUTE_USER=nova_compute" \ + -e "NOVA_PASSWORD=geheim" \ + -e "NOVA_PLACEMENT_USER=placement" \ + -e "NOVA_PLACEMENT_PASSWORD=geheim" \ + -e "RABBIT_USER=openstack" \ + -e "RABBIT_PASSWORD=geheim" \ + -e "RABBIT_HOST={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "MEMCACHED_HOST={{ hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "MYSQL_HOST={{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "MYSQL_ROOT_PASSWORD=geheim" \ + -e "NOVA_CONTROLLER_HOST={{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }}" \ + -e "GLANCE_CONTROLLER_HOST={{ hostvars[groups['glance-controller'][0]]['ansible_default_ipv4']['address'] }}" \ + --add-host=nova-controller:{{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }} \ + --add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }} \ + --add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }} \ + --privileged \ + -v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \ + -v /srv/osdisks:/var/lib/nova/instances \ + hpc/novacompute /etc/run.sh + +[Install] +WantedBy=multi-user.target diff --git a/roles/nova-controller/templates/nova-controller.service b/roles/nova-controller/templates/nova-controller.service index 505756b..e161c45 100644 --- a/roles/nova-controller/templates/nova-controller.service +++ b/roles/nova-controller/templates/nova-controller.service @@ -22,7 +22,6 @@ ExecStart=/usr/bin/docker run --name %n \ -e "NOVA_CONTROLLER_HOST={{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }}" \ -e "GLANCE_CONTROLLER_HOST={{ hostvars[groups['glance-controller'][0]]['ansible_default_ipv4']['address'] }}" \ --add-host=nova-controller:{{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }} \ - --add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }} \ --add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }} \ --privileged \ -p 8774:8774 \