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)