Exemplo n.º 1
0
    def test_configure_operation(self):
        testname = __name__
        ctx = self.get_mock_context(testname)
        current_ctx.set(ctx=ctx)
        user = "******"
        keypair = "/home/fglaser/.ssh/cloudify-agent-kp.pem"
        roles = "roles.zip"
        private_ip_address = "127.0.0.1"
        playbook = "apache.yaml"

        ctx.instance.runtime_properties["keypair"] = keypair
        ctx.instance.runtime_properties["user"] = user
        ctx.instance.runtime_properties["roles"] = roles
        ctx.instance.runtime_properties["private_ip_address"] = private_ip_address
        ctx.instance.runtime_properties["playbook"] = playbook

        tasks.configure(user, keypair, playbook, roles, private_ip_address, ctx=ctx)
        self.assertEqual(os.environ.get("ANSIBLE_CONFIG"), os.path.expanduser("~/.ansible.cfg"))
        self.assertEqual(os.environ.get("USER"), user)
        self.assertEqual(os.environ.get("HOME"), os.path.expanduser("~"))
        configuration = (
            "[defaults]\n"
            "host_key_checking=False\n"
            "private_key_file={0}\n".format(os.path.expanduser(ctx.instance.runtime_properties["key"]))
        )
        with open(os.environ.get("ANSIBLE_CONFIG"), "r") as f:
            content = f.read()
        self.assertEqual(content, configuration)
Exemplo n.º 2
0
    def test_configure_operation(self):
        testname = __name__
        ctx = self.get_mock_context(testname)
        current_ctx.set(ctx=ctx)

        ctx.instance.runtime_properties['key'] = '~/.ssh/agent_key.pem'
        ctx.instance.runtime_properties['user'] = os.getlogin()
        tasks.configure(ctx=ctx)
        self.assertEqual(os.environ.get('ANSIBLE_CONFIG'),
                         os.path.expanduser('~/.ansible.cfg'))
        self.assertEqual(os.environ.get('USER'), os.getlogin())
        self.assertEqual(os.environ.get('HOME'), os.path.expanduser('~'))
        configuration = '[defaults]\n' \
                        'host_key_checking=False\n' \
                        'private_key_file={0}\n'.format(
                            os.path.expanduser(
                                ctx.instance.runtime_properties['key']))
        with open(os.environ.get('ANSIBLE_CONFIG'), 'r') as f:
            content = f.read()
        self.assertEqual(content, configuration)
    def test_configure_operation(self):
        testname = __name__
        ctx = self.get_mock_context(testname)
        current_ctx.set(ctx=ctx)

        ctx.instance.runtime_properties['key'] = '~/.ssh/agent_key.pem'
        ctx.instance.runtime_properties['user'] = os.getlogin()
        tasks.configure(ctx=ctx)
        self.assertEqual(os.environ.get('ANSIBLE_CONFIG'),
                         os.path.expanduser('~/.ansible.cfg'))
        self.assertEqual(os.environ.get('USER'), os.getlogin())
        self.assertEqual(os.environ.get('HOME'), os.path.expanduser('~'))
        configuration = '[defaults]\n' \
                        'host_key_checking=False\n' \
                        'private_key_file={0}\n'.format(
                            os.path.expanduser(
                                ctx.instance.runtime_properties['key']))
        with open(os.environ.get('ANSIBLE_CONFIG'), 'r') as f:
            content = f.read()
        self.assertEqual(content, configuration)