@@ -0,0 +1,2143 @@
+# -*- coding: utf-8 -*-%0A'''%0AManagement of Influxdb databases%0A================================%0A%0A(compatible with InfluxDB version 0.9+)%0A'''%0A%0A%0Adef __virtual__():%0A    '''%0A    Only load if the influxdb module is available%0A    '''%0A    if 'influxdb.db_exists' in __salt__:%0A        return 'influxdb_database'%0A    return False%0A%0A%0Adef present(name, **client_args):%0A    '''%0A    Ensure that given database is present.%0A%0A    name%0A        Name of the database to create.%0A    '''%0A    ret = %7B'name': name,%0A           'changes': %7B%7D,%0A           'result': True,%0A           'comment': 'Database %7B0%7D is already present'.format(name)%7D%0A%0A    if not __salt__%5B'influxdb.db_exists'%5D(name, **client_args):%0A        if __opts__%5B'test'%5D:%0A            ret%5B'result'%5D = None%0A            ret%5B'comment'%5D = 'Database %7B0%7D is absent and will be created'%5C%0A                .format(name)%0A            return ret%0A        if __salt__%5B'influxdb.db_create'%5D(name, **client_args):%0A            ret%5B'comment'%5D = 'Database %7B0%7D has been created'.format(name)%0A            ret%5B'changes'%5D%5Bname%5D = 'Present'%0A            return ret%0A        else:%0A            ret%5B'comment'%5D = 'Failed to create database %7B0%7D'.format(name)%0A            ret%5B'result'%5D = False%0A            return ret%0A%0A    return ret%0A%0A%0Adef absent(name, **client_args):%0A    '''%0A    Ensure that given database is absent.%0A%0A    name%0A        Name of the database to remove.%0A    '''%0A    ret = %7B'name': name,%0A           'changes': %7B%7D,%0A           'result': True,%0A           'comment': 'Database %7B0%7D is not present'.format(name)%7D%0A%0A    if __salt__%5B'influxdb.db_exists'%5D(name, **client_args):%0A        if __opts__%5B'test'%5D:%0A            ret%5B'result'%5D = None%0A            ret%5B'comment'%5D = 'Database %7B0%7D is present and needs to be removed'%5C%0A                .format(name)%0A            return ret%0A        if __salt__%5B'influxdb.db_remove'%5D(name, **client_args):%0A            ret%5B'comment'%5D = 'Database %7B0%7D has been removed'.format(name)%0A            ret%5B'changes'%5D%5Bname%5D = 'Absent'%0A            return ret%0A        else:%0A            ret%5B'comment'%5D = 'Failed to remove database %7B0%7D'.format(name)%0A            ret%5B'result'%5D = False%0A            return ret%0A%0A    return ret%0A

Add state module to manage InfluxDB databases