-
-
Save rafaelnovello/4505288 to your computer and use it in GitHub Desktop.
Alteração no VagrantFile para correção de erros ao levantar a VM. O método forward_port recebe apenas dois argumentos e o método network precisa da definição de hostonly ou bridged. A instrução update_file estava com o caminho e o owner errados. Alterado de frontend para backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from provy.core import Role | |
class FrontEnd(Role): | |
def provision(self): | |
pass | |
class BackEnd(Role): | |
def provision(self): | |
pass | |
servers = { | |
'test': { | |
'frontend': { | |
'address': '33.33.33.33', | |
'user': 'vagrant', | |
'roles': [ | |
FrontEnd | |
] | |
}, | |
'backend': { | |
'address': '33.33.33.34', | |
'user': 'vagrant', | |
'roles': [ | |
BackEnd | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from provy.core import Role | |
from provy.more.debian import UserRole | |
class FrontEnd(Role): | |
def provision(self): | |
pass | |
class BackEnd(Role): | |
def provision(self): | |
with self.using(UserRole) as role: | |
role.ensure_user('backend', identified_by='pass', is_admin=True) | |
servers = { | |
'test': { | |
'frontend': { | |
'address': '33.33.33.33', | |
'user': 'vagrant', | |
'roles': [ | |
FrontEnd | |
] | |
}, | |
'backend': { | |
'address': '33.33.33.34', | |
'user': 'vagrant', | |
'roles': [ | |
BackEnd | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from provy.core import Role | |
from provy.more.debian import UserRole | |
class FrontEnd(Role): | |
def provision(self): | |
pass | |
class BackEnd(Role): | |
def provision(self): | |
with self.using(UserRole) as role: | |
role.ensure_user('backend', identified_by='pass', is_admin=True) | |
self.update_file('website.py', '/home/backend/website.py', owner='backend') | |
servers = { | |
'test': { | |
'frontend': { | |
'address': '33.33.33.33', | |
'user': 'vagrant', | |
'roles': [ | |
FrontEnd | |
] | |
}, | |
'backend': { | |
'address': '33.33.33.34', | |
'user': 'vagrant', | |
'roles': [ | |
BackEnd | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python website.py 8000 | |
>> Website running at http://0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# will provision both servers | |
$ provy -s test | |
# will provision only the frontend server | |
$ provy -s test.frontend | |
# will provision only the backend server | |
$ provy -s test.backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from provy.core import Role | |
from provy.more.debian import UserRole, AptitudeRole | |
class SimpleServer(Role): | |
def provision(self): | |
with self.using(UserRole) as role: | |
role.ensure_user('my-user', identified_by='my-pass', is_admin=True) | |
with self.using(AptitudeRole) as role: | |
role.ensure_package_installed('vim') | |
servers = { | |
'frontend': { | |
'address': '33.33.33.33', | |
'user': 'root', | |
'roles': [ | |
SimpleServer | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vagrant box add base http://files.vagrantup.com/lucid32.box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vagrant init | |
create Vagrantfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant::Config.run do |config| | |
config.vm.define "frontend" do |inner_config| | |
inner_config.vm.box = "base" | |
inner_config.vm.forward_port(80, 8080) | |
inner_config.vm.network :hostonly,"33.33.33.33" | |
end | |
config.vm.define "backend" do |inner_config| | |
inner_config.vm.box = "base" | |
inner_config.vm.forward_port(80, 8081) | |
inner_config.vm.network :hostonly,"33.33.33.34" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sys | |
import tornado.ioloop | |
import tornado.web | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Hello, world") | |
application = tornado.web.Application([ | |
(r"/", MainHandler), | |
]) | |
if __name__ == "__main__": | |
port = int(sys.argv[1]) | |
application.listen(port, '0.0.0.0') | |
print ">> Website running at http://0.0.0.0:%d" % port | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment