Commits

Mikhail Korobov  committed 161c4b6

Fixing Debian support after sudo_refactor merge

  • Participants
  • Parent commits 7be3dfd

Comments (0)

Files changed (6)

File fab_deploy/system.py

 from fab_deploy import utils
 
 
-__all__ = ['create_linux_account', 'create_sudo_linux_account', 'ssh_add_key']
+__all__ = ['create_linux_account', 'create_sudo_linux_account', 'ssh_add_key', 'install_sudo']
 
 
 def prepare_server():
     sudo('pip install -U virtualenv')
 
 
+@utils.run_as_sudo
 def setup_backports():
     """ Adds backports repo to apt sources. """
     os = utils.detect_os()

File fab_deploy_tests/preparevm.py

 import sys
 from fabric.api import env, run
 from fabtest import fab, VirtualBox
-from utils import setup_ssh
+from utils import setup_ssh, setup_sudo, private_key_path
 
 from fab_deploy.utils import update_env
 from fab_deploy.system import prepare_server
 
     It now prepares an extra snapshot with basic software,
     apache, nginx and mysql installed.
+
+    VM is not executed in headless mode because snapshot taking
+    seems to be broken in this mode.
     """
     env.hosts = ['foo@127.0.0.1:2222']
     env.password = '123'
     env.disable_known_hosts = True
     env.conf = {'DB_PASSWORD': '123'}
+    env.key_filename = private_key_path()
     update_env()
 
     box = VirtualBox(name)
 
     if not box.snapshot_exists('fabtest-prepared-server'):
         activate_snapshot(box, 'fabtest-initial')
+        setup_sudo()
         setup_ssh()
         fab(prepare_server)
         fab(apache_install)

File fab_deploy_tests/tests/mysql.py

 from fabric.api import *
 from fabtest import fab
 from fab_deploy.mysql import mysql_install, _mysql_is_installed, mysql_create_db, mysql_execute
+from ..utils import setup_sudo
 from .base import FabDeployTest
 
 def mysql_is_installed():
         env.conf['DB_NAME'] = 'new_database'
 
     def test_mysql(self):
+        setup_sudo()
+
         self.assertFalse(mysql_is_installed())
 
         fab(mysql_install)

File fab_deploy_tests/tests/system_tests.py

 from fab_deploy.apache import apache_install
 from fab_deploy.nginx import nginx_install
 
-from fab_deploy_tests.utils import setup_ssh, public_key_path
+from fab_deploy_tests.utils import setup_ssh, public_key_path, setup_sudo
 from .base import FabDeployTest
 
 @run_as('root')
         self.assertPackageInstalled('python-minimal')
 
     def test_create_linux_account(self):
+        setup_sudo()
         setup_ssh()
         def command():
             self.assertUserIs('foo')
 
 class PrepareServerTest(FabDeployTest):
     def test_prepare_server_ok(self):
+        setup_sudo()
         setup_ssh()
 
         fab(prepare_server)

File fab_deploy_tests/tests/utils_tests.py

 from fab_deploy.utils import run_as
 from fab_deploy.system import create_sudo_linux_account
 from .base import FabDeployTest
-from ..utils import public_key_path
+from ..utils import public_key_path, setup_sudo
 
 @run_as('root')
 def whoami():
         self.assertEqual(user, 'root')
 
     def test_create_sudo_linux_account(self):
+        setup_sudo()
         fab(create_sudo_linux_account, public_key_path(), 'testsudo')
 
         @run_as('testsudo')

File fab_deploy_tests/utils.py

 from fabric.api import run
 from fabtest import fab
 from fab_deploy.utils import run_as
-from fab_deploy.system import create_linux_account
+from fab_deploy.system import create_linux_account, install_sudo
 
 def public_key_path():
     return os.path.join(os.path.dirname(__file__), 'keys', 'id_rsa.pub')
 
 def setup_ssh():
     fab(create_linux_account, public_key_path())
+
+def setup_sudo():
+    fab(install_sudo)