def present(self): ''' Handles state == 'present', creating or updating the secret ''' secret = self.get_secret() if secret: self.results['secret_id'] = secret['ID'] data_changed = False attrs = secret.get('Spec', {}) if attrs.get('Labels', {}).get('ansible_key'): if attrs['Labels']['ansible_key'] != self.data_key: data_changed = True else: if not self.force: self.client.module.warn( "'ansible_key' label not found. Secret will not be changed unless the force parameter is set to 'yes'" ) labels_changed = not compare_generic( self.labels, attrs.get('Labels'), 'allow_more_present', 'dict') if data_changed or labels_changed or self.force: # if something changed or force, delete and re-create the secret self.absent() secret_id = self.create_secret() self.results['changed'] = True self.results['secret_id'] = secret_id else: self.results['changed'] = True self.results['secret_id'] = self.create_secret()
def present(self): ''' Handles state == 'present', creating or updating the config ''' config = self.get_config() if config: self.results['config_id'] = config['ID'] data_changed = False attrs = config.get('Spec', {}) if attrs.get('Labels', {}).get('ansible_key'): if attrs['Labels']['ansible_key'] != self.data_key: data_changed = True labels_changed = not compare_generic(self.labels, attrs.get('Labels'), 'allow_more_present', 'dict') if data_changed or labels_changed or self.force: # if something changed or force, delete and re-create the config self.absent() config_id = self.create_config() self.results['changed'] = True self.results['config_id'] = config_id else: self.results['changed'] = True self.results['config_id'] = self.create_config()