[
https://issues.apache.org/jira/browse/METRON-671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899405#comment-15899405
]
ASF GitHub Bot commented on METRON-671:
---------------------------------------
Github user justinleet commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/436#discussion_r104654194
--- Diff: metron-deployment/extra_modules/ambari_service_state.py ---
@@ -0,0 +1,352 @@
+#!/usr/bin/python
+#
+# 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.
+#
+
+DOCUMENTATION = '''
+---
+module: ambari_service_state
+version_added: "2.1"
+author: Apache Metron (Incubating :
https://github.com/apache/incubator-metron )
+short_description: Start/Stop/Change Service or Component State
+description:
+ - Start/Stop/Change Service or Component State
+options:
+ host:
+ description:
+ The hostname for the ambari web server
+ port:
+ description:
+ The port for the ambari web server
+ username:
+ description:
+ The username for the ambari web server
+ password:
+ description:
+ The name of the cluster in web server
+ required: yes
+ cluster_name:
+ description:
+ The name of the cluster in ambari
+ required: yes
+ service_name:
+ description:
+ The name of the service to alter
+ required: no
+ component_name:
+ description:
+ The name of the component to alter
+ required: no
+ component_host:
+ description:
+ The host running the targeted component. Required when
component_name is used.
+ required: no
+ state:
+ description:
+ The desired service/component state.
+ wait_for_complete:
+ description:
+ Whether to wait for the request to complete before returning.
Default is False.
+ required: no
+ requirements: [ 'requests']
+'''
+
+EXAMPLES = '''
+# must use full relative path to any files in stored in
roles/role_name/files/
+- name: Create a new ambari cluster
+ ambari_cluster_state:
+ host: localhost
+ port: 8080
+ username: admin
+ password: admin
+ cluster_name: my_cluster
+ cluster_state: present
+ blueprint_var: roles/my_role/files/blueprint.yml
+ blueprint_name: hadoop
+ wait_for_complete: True
+- name: Start the ambari cluster
+ ambari_cluster_state:
+ host: localhost
+ port: 8080
+ username: admin
+ password: admin
+ cluster_name: my_cluster
+ cluster_state: started
+ wait_for_complete: True
+- name: Stop the ambari cluster
+ ambari_cluster_state:
+ host: localhost
+ port: 8080
+ username: admin
+ password: admin
+ cluster_name: my_cluster
+ cluster_state: stopped
+ wait_for_complete: True
+- name: Delete the ambari cluster
+ ambari_cluster_state:
+ host: localhost
+ port: 8080
+ username: admin
+ password: admin
+ cluster_name: my_cluster
+ cluster_state: absent
+'''
+
+RETURN = '''
+results:
+ description: The content of the requests object returned from the
RESTful call
+ returned: success
+ type: string
+'''
+
+__author__ = 'apachemetron'
+
+import json
+
+try:
+ import requests
+except ImportError:
+ REQUESTS_FOUND = False
+else:
+ REQUESTS_FOUND = True
+
+
+def main():
+
+ argument_spec = dict(
+ host=dict(type='str', default=None, required=True),
+ port=dict(type='int', default=None, required=True),
+ username=dict(type='str', default=None, required=True),
+ password=dict(type='str', default=None, required=True),
+ cluster_name=dict(type='str', default=None, required=True),
+ state=dict(type='str', default=None, required=True,
+ choices=['started', 'stopped', 'deleted']),
+ service_name=dict(type='str', required=False),
+ component_name=dict(type='str', default=None, required=False),
+ component_host=dict(type='str', default=None, required=False),
+ wait_for_complete=dict(default=False, required=False,
choices=BOOLEANS),
+ )
+
+ required_together = ['component_name', 'component_host']
+
+ module = AnsibleModule(
+ argument_spec=argument_spec,
+ required_together=required_together
+ )
+
+ if not REQUESTS_FOUND:
+ module.fail_json(
+ msg='requests library is required for this module')
+
+ p = module.params
+
+ host = p.get('host')
+ port = p.get('port')
+ username = p.get('password')
--- End diff --
Should be `p.get('username')`, correct? I haven't run everything up yet,
but it seems like it should break things further down in the script.
> Refactor existing Ansible deployment to use Ambari MPack
> --------------------------------------------------------
>
> Key: METRON-671
> URL: https://issues.apache.org/jira/browse/METRON-671
> Project: Metron
> Issue Type: Bug
> Reporter: David M. Lyle
> Assignee: David M. Lyle
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)