Simplify the Vagrant environment

Change-Id: Iaa525d41ded0c225d28277cd0842b3cf630d7713
This commit is contained in:
Christian Berendt 2015-03-24 19:42:42 +01:00
parent 71c6f25ba0
commit 0066eec8ca
13 changed files with 41 additions and 117 deletions

View File

@ -5,5 +5,4 @@ Documentation
-------------
.. image:: https://readthedocs.org/projects/first-app-application-for-openstack/badge/?version=latest
:target: https://readthedocs.org/projects/first-app-application-for-openstack/?badge=latest
:alt: Documentation Status
:target: http://first-app-application-for-openstack.readthedocs.org/en/latest/

62
Vagrantfile vendored
View File

@ -13,67 +13,19 @@
# License for the specific language governing permissions and limitations
# under the License.
BOX = 'ubuntu/trusty64'
Vagrant.configure(2) do |config|
config.vm.box = BOX
config.vm.box = 'ubuntu/trusty64'
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--memory', '1024']
vb.customize ['modifyvm', :id, '--cpus', '1']
end
config.ssh.shell = 'bash -c "BASH_ENV=/etc/profile exec bash"'
config.cache.scope = :box if Vagrant.has_plugin?('vagrant-cachier')
config.hostmanager.enabled = true
config.hostmanager.include_offline = true
config.vm.define 'service', primary: true do |service|
service.vm.hostname = 'service'
service.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = %w(database messaging)
end
service.vm.network :private_network, ip: '10.15.15.10'
service.vm.network 'forwarded_port', guest: 15_672, host: 15_672
end
config.vm.define 'worker' do |worker|
worker.vm.hostname = 'worker'
worker.vm.network :private_network, ip: '10.15.15.20'
worker.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = 'worker'
end
end
config.vm.define 'tracker' do |tracker|
tracker.vm.hostname = 'tracker'
tracker.vm.network :private_network, ip: '10.15.15.30'
tracker.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = 'tracker'
end
end
config.vm.define 'producer' do |producer|
producer.vm.hostname = 'producer'
producer.vm.network :private_network, ip: '10.15.15.40'
producer.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = 'producer'
end
end
config.vm.define 'api' do |api|
api.vm.hostname = 'api'
api.vm.network :private_network, ip: '10.15.15.50'
api.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = 'api'
end
api.vm.network 'forwarded_port', guest: 5000, host: 5000
end
config.vm.define 'webinterface' do |webinterface|
webinterface.vm.hostname = 'webinterface'
webinterface.vm.network :private_network, ip: '10.15.15.60'
webinterface.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
ansible.tags = 'webinterface'
end
webinterface.vm.network 'forwarded_port', guest: 80, host: 8000
config.vm.hostname = 'faafo'
config.vm.provision 'ansible' do |ansible|
ansible.playbook = 'ansible/playbook.yaml'
end
config.vm.network 'forwarded_port', guest: 80, host: 8000
config.vm.network 'forwarded_port', guest: 5000, host: 5000
config.vm.network 'forwarded_port', guest: 15_672, host: 15_672
end

View File

@ -1,5 +1,5 @@
#!/bin/sh
faafo-api \
--database-url mysql://tutorial:secretsecret@service:3306/tutorial \
--database-url mysql://faafo:secretsecret@127.0.0.1:3306/faafo \
--debug --verbose

View File

@ -1,6 +1,6 @@
#!/bin/sh
faafo-producer \
--amqp-url amqp://tutorial:secretsecret@service:5672/ \
--api-url http://api:5000 \
--amqp-url amqp://faafo:secretsecret@127.0.0.1:5672/ \
--api-url http://127.0.0.1:5000 \
--debug --verbose

View File

@ -1,6 +1,6 @@
#!/bin/sh
faafo-tracker \
--amqp-url amqp://tutorial:secretsecret@service:5672/ \
--api-url http://api:5000 \
--amqp-url amqp://faafo:secretsecret@127.0.0.1:5672/ \
--api-url http://127.0.0.1:5000 \
--debug --verbose

View File

@ -1,6 +1,6 @@
#!/bin/sh
faafo-worker \
--amqp-url amqp://tutorial:secretsecret@service:5672/ \
--amqp-url amqp://faafo:secretsecret@127.0.0.1:5672/ \
--target /home/vagrant \
--debug --verbose

View File

@ -4,9 +4,9 @@
tasks:
- apt: update-cache=yes upgrade=yes
- include: tasks/database.yaml tags=database
- include: tasks/messaging.yaml tags=messaging
- include: tasks/webinterface.yaml tags=webinterface
- include: tasks/database.yaml
- include: tasks/messaging.yaml
- include: tasks/webinterface.yaml
- apt: name={{ item }} state=latest
with_items:
@ -14,33 +14,13 @@
- libmysqlclient-dev
- python-dev
- python-virtualenv
tags:
- api
- producer
- tracker
- worker
- command: pip install -r /vagrant/requirements.txt
tags:
- api
- producer
- tracker
- worker
- command: python setup.py install
args:
chdir: /vagrant
tags:
- api
- producer
- tracker
- worker
- copy: src=files/run_api.sh dest=/home/vagrant/run_api.sh mode=0755
tags: api
- copy: src=files/run_producer.sh dest=/home/vagrant/run_producer.sh mode=0755
tags: producer
- copy: src=files/run_tracker.sh dest=/home/vagrant/run_tracker.sh mode=0755
tags: tracker
- copy: src=files/run_worker.sh dest=/home/vagrant/run_worker.sh mode=0755
tags: worker
- copy: src=files/run_api.sh dest=/home/vagrant/run_api.sh mode=0755 owner=vagrant group=vagrant
- copy: src=files/run_producer.sh dest=/home/vagrant/run_producer.sh mode=0755 owner=vagrant group=vagrant
- copy: src=files/run_tracker.sh dest=/home/vagrant/run_tracker.sh mode=0755 owner=vagrant group=vagrant
- copy: src=files/run_worker.sh dest=/home/vagrant/run_worker.sh mode=0755 owner=vagrant group=vagrant

View File

@ -13,11 +13,5 @@
- command: /root/mysql_secure_installation.sh
creates=/root/mysql_secure_installation.done
- copy: src=files/client.my.cnf dest=/root/.my.cnf
- mysql_db: name=tutorial state=present
- mysql_user: name=tutorial password=secretsecret priv=*.*:ALL host={{ item }} state=present
with_items:
- api
- localhost
- producer
- tracker
- worker
- mysql_db: name=faafo state=present
- mysql_user: name=faafo password=secretsecret priv=*.*:ALL host=localhost state=present

View File

@ -5,7 +5,7 @@
- service: name=rabbitmq-server state=started enabled=yes
- rabbitmq_user: user=guest
password=secretsecret
- rabbitmq_user: user=tutorial
- rabbitmq_user: user=faafo
password=secretsecret
vhost=/
configure_priv=.*

View File

@ -9,12 +9,6 @@ playbook is used only for local tests and development of the application.
The installation of Vagrant is described at https://docs.vagrantup.com/v2/installation/index.html.
The Vagrant plugin `vagrant-hostmanager <https://github.com/smdahlen/vagrant-hostmanager>`_ is required.
.. code::
$ vagrant plugin install vagrant-hostmanager
To speedup the provisioning you can install the Vagrant plugin `vagrant-cachier <https://github.com/fgrehm/vagrant-cachier>`_.
.. code::
@ -27,14 +21,19 @@ Bootstrap the Vagrant environment.
$ vagrant up
The RabbitMQ server and the MySQL server are running on the machine :code:`service.`
Now it is possible to login with SSH.
There is a machine for each service of the tutorial application:
.. code::
* :code:`api` - :code:`vagrant ssh api` - :code:`sh run_api.sh`
* :code:`producer` - :code:`vagrant ssh producer` - :code:`sh run_producer.sh`
* :code:`tracker` - :code:`vagrant ssh tracker` - :code:`sh run_tracker.sh`
* :code:`worker` - :code:`vagrant ssh worker` - :code:`sh run_worker.sh`
$ vagrant ssh
Open a new screen or tmux session. Aftwards run the api, worker, producer, and
tracker services in the foreground, each service in a separate window.
* :code:`sh run_api.sh`
* :code:`sh run_producer.sh`
* :code:`sh run_tracker.sh`
* :code:`sh run_worker.sh`
RabbitMQ server
~~~~~~~~~~~~~~~
@ -45,8 +44,8 @@ possible with the user :code:`guest` and the password :code:`secretsecret`.
MySQL server
~~~~~~~~~~~~
The password of the user :code:`root` is :code:`secretsecret`. The password of the user :code:`tutorial`
for the database :code:`tutorial` is also :code:`secretsecret`.
The password of the user :code:`root` is :code:`secretsecret`. The password of the user :code:`faafo`
for the database :code:`faafo` is also :code:`secretsecret`.
Virtual environment
-------------------
@ -61,7 +60,7 @@ the application itself.
$ pip install -r requirements.txt
$ python setup.py install
Now open a new screen or tmux session. Aftwards run the api, worker, producer, and
Open a new screen or tmux session. Aftwards run the api, worker, producer, and
tracker services in the foreground, each service in a separate window.
.. code::

View File

@ -36,7 +36,7 @@ cli_opts = [
default=False,
help='Run in background.'),
cfg.StrOpt('amqp-url',
default='amqp://tutorial:secretsecret@localhost:5672/',
default='amqp://faafo:secretsecret@localhost:5672/',
help='AMQP connection URL'),
cfg.StrOpt('api-url',
default='http://localhost:5000',

View File

@ -35,7 +35,7 @@ cli_opts = [
default=False,
help='Run in background.'),
cfg.StrOpt('amqp-url',
default='amqp://tutorial:secretsecret@localhost:5672/',
default='amqp://faafo:secretsecret@localhost:5672/',
help='AMQP connection URL'),
cfg.StrOpt('api-url',
default='http://localhost:5000',

View File

@ -42,7 +42,7 @@ cli_opts = [
default='/tmp',
help='Target directory for fractal image files.'),
cfg.StrOpt('amqp-url',
default='amqp://tutorial:secretsecret@localhost:5672/',
default='amqp://faafo:secretsecret@localhost:5672/',
help='AMQP connection URL')
]