Repository: ambari Updated Branches: refs/heads/trunk 2a4f67ae9 -> 42cf9b21c
AMBARI-7976. Ambari: Add oozie install user as an Oozie admin user (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/42cf9b21 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/42cf9b21 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/42cf9b21 Branch: refs/heads/trunk Commit: 42cf9b21c593f64bf13d53b8272b62bc73e28c85 Parents: 2a4f67a Author: Andrew Onishuk <[email protected]> Authored: Sun Oct 26 18:31:52 2014 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Sun Oct 26 18:31:52 2014 +0200 ---------------------------------------------------------------------- .../libraries/functions/__init__.py | 1 + .../HDP/2.0.6/services/OOZIE/metainfo.xml | 2 +- .../services/OOZIE/package/scripts/oozie.py | 18 ++++-- .../services/OOZIE/package/scripts/params.py | 2 +- .../OOZIE/package/templates/adminusers.txt.j2 | 24 ++++++++ .../services/OOZIE/configuration/oozie-site.xml | 2 +- .../stacks/2.0.6/OOZIE/test_oozie_client.py | 60 ++++++++++++++++++++ 7 files changed, 101 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py index 3d92d64..e72512c 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py @@ -29,3 +29,4 @@ from resource_management.libraries.functions.is_empty import * from resource_management.libraries.functions.substitute_vars import * from resource_management.libraries.functions.get_port_from_url import * from resource_management.libraries.functions.hive_check import * +from resource_management.libraries.functions.version import * http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml index 9d4247e..ec66213 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/metainfo.xml @@ -100,7 +100,7 @@ <type>env</type> <fileName>oozie-log4j.properties</fileName> <dictionaryName>oozie-log4j</dictionaryName> - </configFile> + </configFile> </configFiles> </component> </components> http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/oozie.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/oozie.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/oozie.py index bba2e09..19c334c 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/oozie.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/oozie.py @@ -63,6 +63,19 @@ def oozie(is_server=False # TODO: see if see can remove this owner=params.oozie_user ) + if params.stack_is_hdp22_or_further: + File(format("{params.conf_dir}/adminusers.txt"), + mode=0644, + group=params.user_group, + owner=params.oozie_user, + content=Template('adminusers.txt.j2', oozie_user=params.oozie_user) + ) + else: + File ( format("{params.conf_dir}/adminusers.txt"), + owner = params.oozie_user, + group = params.user_group + ) + environment = { "no_proxy": format("{ambari_server_hostname}") } @@ -87,11 +100,6 @@ def oozie_ownership( ): import params - File ( format("{conf_dir}/adminusers.txt"), - owner = params.oozie_user, - group = params.user_group - ) - File ( format("{conf_dir}/hadoop-config.xml"), owner = params.oozie_user, group = params.user_group http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/params.py index 3960904..261ed55 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/params.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/scripts/params.py @@ -27,7 +27,7 @@ config = Script.get_config() tmp_dir = Script.get_tmp_dir() hdp_stack_version = str(config['hostLevelParams']['stack_version']) -stack_is_hdp22_or_further = not (hdp_stack_version.startswith('2.0') or hdp_stack_version.startswith('2.1')) +stack_is_hdp22_or_further = functions.version.compare_versions(hdp_stack_version, '2.1') >= 1 #hadoop params if stack_is_hdp22_or_further: http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/templates/adminusers.txt.j2 ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/templates/adminusers.txt.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/templates/adminusers.txt.j2 new file mode 100644 index 0000000..9feae39 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/OOZIE/package/templates/adminusers.txt.j2 @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Users should be set using following rules: +# +# One user name per line +# Empty lines and lines starting with '#' are ignored + +{{oozie_user}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/main/resources/stacks/HDP/2.2/services/OOZIE/configuration/oozie-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/OOZIE/configuration/oozie-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/OOZIE/configuration/oozie-site.xml index 4a8eab7..e44cb57 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/OOZIE/configuration/oozie-site.xml +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/OOZIE/configuration/oozie-site.xml @@ -80,7 +80,7 @@ <property> <name>oozie.service.AuthorizationService.security.enabled</name> - <value>false</value> + <value>true</value> <description> Specifies whether security (user name/admin role) is enabled or not. If disabled any user can manage Oozie system and manage any job. http://git-wip-us.apache.org/repos/asf/ambari/blob/42cf9b21/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py index 7afbf96..67482b4 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py @@ -19,6 +19,7 @@ limitations under the License. ''' from mock.mock import MagicMock, call, patch from stacks.utils.RMFTestCase import * +import json class TestOozieClient(RMFTestCase): @@ -124,3 +125,62 @@ class TestOozieClient(RMFTestCase): group = 'hadoop', ) self.assertNoMoreResources() + + def test_configure_default_hdp22(self): + config_file = "stacks/2.0.6/configs/default.json" + with open(config_file, "r") as f: + default_json = json.load(f) + + + default_json['hostLevelParams']['stack_version']= '2.2' + self.executeScript("2.0.6/services/OOZIE/package/scripts/oozie_client.py", + classname = "OozieClient", + command = "configure", + config_dict=default_json + ) + self.assertResourceCalled('Directory', '/etc/oozie/conf', + owner = 'oozie', + group = 'hadoop', + recursive = True + ) + self.assertResourceCalled('XmlConfig', 'oozie-site.xml', + owner = 'oozie', + group = 'hadoop', + mode = 0664, + conf_dir = '/etc/oozie/conf', + configurations = self.getConfig()['configurations']['oozie-site'], + configuration_attributes = self.getConfig()['configuration_attributes']['oozie-site'] + ) + self.assertResourceCalled('File', '/etc/oozie/conf/oozie-env.sh', + owner = 'oozie', + content = InlineTemplate(self.getConfig()['configurations']['oozie-env']['content']) + ) + self.assertResourceCalled('File', '/etc/oozie/conf/oozie-log4j.properties', + owner = 'oozie', + group = 'hadoop', + mode = 0644, + content = 'log4jproperties\nline2' + ) + self.assertResourceCalled('File', '/etc/oozie/conf/adminusers.txt', + content = Template('adminusers.txt.j2'), + owner = 'oozie', + group = 'hadoop', + mode=0644, + ) + self.assertResourceCalled('File', '/etc/oozie/conf/hadoop-config.xml', + owner = 'oozie', + group = 'hadoop', + ) + self.assertResourceCalled('File', '/etc/oozie/conf/oozie-default.xml', + owner = 'oozie', + group = 'hadoop', + ) + self.assertResourceCalled('Directory', '/etc/oozie/conf/action-conf', + owner = 'oozie', + group = 'hadoop', + ) + self.assertResourceCalled('File', '/etc/oozie/conf/action-conf/hive.xml', + owner = 'oozie', + group = 'hadoop', + ) + self.assertNoMoreResources()
