本文整理汇总了Python中ansible.runner.Runner.get方法的典型用法代码示例。如果您正苦于以下问题:Python Runner.get方法的具体用法?Python Runner.get怎么用?Python Runner.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.runner.Runner
的用法示例。
在下文中一共展示了Runner.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Runner
# 需要导入模块: from ansible.runner import Runner [as 别名]
# 或者: from ansible.runner.Runner import get [as 别名]
databases = ['scm', 'amon', 'rman', 'metastore']
for db in databases:
owner = db
if db == 'metastore':
owner = 'hive'
log.debug("Creating database {0} with owner {1}".format(db, owner))
try:
r = Runner(inventory=Inventory(['localhost']),
transport='local',
sudo=True,
sudo_user='postgres',
module_name="postgresql_db",
module_args=("name={0} owner={1} encoding='UTF-8'"
.format(db, owner))
).run()
if r.get('contacted', {}).get('localhost', {}).get('failed'):
msg = r.get('contacted', {}).get('localhost', {}).get('msg', 'N/A')
log.error("Creating the database filed: {0}".format(msg))
except Exception, e:
log.error("Exception creating database {0}: {1}".format(db, e))
# Alter one of the DBs
sql_cmds = [
"ALTER DATABASE metastore SET standard_conforming_strings = off"
]
for sql_cmd in sql_cmds:
misc.run_psql_command(sql_cmd, 'postgres', self.app.path_resolver.psql_cmd, 5432)
# Prepare the scm database
cmd = ("/usr/share/cmf/schema/scm_prepare_database.sh -h localhost postgresql scm scm {0}"
.format(self.db_pwd))
misc.run(cmd)
# Make sure we have a clean DB env