def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( database_name=dict(required=True, type='str'), state=dict(default='present', type='str', choices=['present', 'absent']) ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) state = module.params['state'] influxdb = InfluxDb(module) client = influxdb.connect_to_influxdb() database_name = influxdb.database_name database = find_database(module, client, database_name) if state == 'present': if database: module.exit_json(changed=False) else: create_database(module, client, database_name) if state == 'absent': if database: drop_database(module, client, database_name) else: module.exit_json(changed=False)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update(state=dict(default='present', type='str', choices=['present', 'absent']), user_name=dict(required=True, type='str'), user_password=dict(required=False, type='str', no_log=True), admin=dict(default='False', type='bool')) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) state = module.params['state'] user_name = module.params['user_name'] user_password = module.params['user_password'] admin = module.params['admin'] influxdb = InfluxDb(module) client = influxdb.connect_to_influxdb() user = find_user(module, client, user_name) if state == 'present': if user: module.exit_json(changed=False) else: create_user(module, client, user_name, user_password, admin) if state == 'absent': if user: drop_user(module, client, user_name) else: module.exit_json(changed=False)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( database_name=dict(required=True, type='str'), state=dict(default='present', type='str', choices=['present', 'absent']) ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) state = module.params['state'] influxdb = InfluxDb(module) client = influxdb.connect_to_influxdb() database_name = influxdb.database_name database = find_database(module, client, database_name) if state == 'present': if database: module.exit_json(changed=False) else: create_database(module, client, database_name) if state == 'absent': if database: drop_database(module, client, database_name) else: module.exit_json(changed=False)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update(database_name=dict(required=True, type='str'), policy_name=dict(required=True, type='str'), duration=dict(required=True, type='str'), replication=dict(required=True, type='int'), default=dict(default=False, type='bool')) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) influxdb = InfluxDb(module) client = influxdb.connect_to_influxdb() retention_policy = find_retention_policy(module, client) if retention_policy: alter_retention_policy(module, client, retention_policy) else: create_retention_policy(module, client)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( data_points=dict(required=True, type='list', elements='dict'), database_name=dict(required=True, type='str'), ) module = AnsibleModule(argument_spec=argument_spec, ) influx = AnsibleInfluxDBWrite(module) data_points = module.params.get('data_points') influx.write_data_point(data_points) module.exit_json(changed=True)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( query=dict(type='str', required=True), database_name=dict(required=True, type='str'), ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) influx = AnsibleInfluxDBRead(module) query = module.params.get('query') results = influx.read_by_query(query) module.exit_json(changed=True, results=results)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( database_name=dict(required=True, type='str'), policy_name=dict(required=True, type='str'), duration=dict(required=True, type='str'), replication=dict(required=True, type='int'), default=dict(default=False, type='bool') ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) influxdb = InfluxDb(module) client = influxdb.connect_to_influxdb() retention_policy = find_retention_policy(module, client) if retention_policy: alter_retention_policy(module, client, retention_policy) else: create_retention_policy(module, client)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( data_points=dict(required=True, type='list'), database_name=dict(required=True, type='str'), ) module = AnsibleModule( argument_spec=argument_spec, ) influx = AnsibleInfluxDBWrite(module) data_points = module.params.get('data_points') influx.write_data_point(data_points) module.exit_json(changed=True)
def main(): argument_spec = InfluxDb.influxdb_argument_spec() argument_spec.update( query=dict(type='str', required=True), database_name=dict(required=True, type='str'), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True ) influx = AnsibleInfluxDBRead(module) query = module.params.get('query') results = influx.read_by_query(query) module.exit_json(changed=True, query_results=results)