Exemplo n.º 1
0
    def present(self):
        differences = DifferenceTracker()
        if self.existing_volume:
            differences = self.has_different_config()

        self.diff_tracker.add('exists',
                              parameter=True,
                              active=self.existing_volume is not None)
        if (not differences.empty and self.parameters.recreate
                == 'options-changed') or self.parameters.recreate == 'always':
            self.remove_volume()
            self.existing_volume = None

        self.create_volume()

        if self.diff or self.check_mode or self.parameters.debug:
            self.diff_result[
                'differences'] = differences.get_legacy_docker_diffs()
            self.diff_tracker.merge(differences)

        if not self.check_mode and not self.parameters.debug:
            self.results.pop('actions')

        volume_facts = self.get_existing_volume()
        self.results['ansible_facts'] = {u'docker_volume': volume_facts}
        self.results['volume'] = volume_facts
Exemplo n.º 2
0
    def present(self):
        different = False
        differences = DifferenceTracker()
        if self.existing_network:
            different, differences = self.has_different_config(
                self.existing_network)

        self.diff_tracker.add('exists',
                              parameter=True,
                              active=self.existing_network is not None)
        if self.parameters.force or different:
            self.remove_network()
            self.existing_network = None

        self.create_network()
        self.connect_containers()
        if not self.parameters.appends:
            self.disconnect_missing()

        if self.diff or self.check_mode or self.parameters.debug:
            self.diff_result[
                'differences'] = differences.get_legacy_docker_diffs()
            self.diff_tracker.merge(differences)

        if not self.check_mode and not self.parameters.debug:
            self.results.pop('actions')

        network_facts = self.get_existing_network()
        self.results['ansible_facts'] = {u'docker_network': network_facts}
        self.results['network'] = network_facts
Exemplo n.º 3
0
    def enable(self):
        differences = DifferenceTracker()

        if self.existing_plugin:
            differences = self.has_different_config()

        self.diff_tracker.add('exists',
                              parameter=True,
                              active=self.existing_plugin is not None)

        # Plugin already exists
        if not differences.empty:
            # Let's update plugin
            self.update_plugin(differences)
        else:
            # Or install and enable plugin
            self.install_plugin()
            self.enable_plugin()

        if self.diff or self.check_mode or self.parameters.debug:
            self.results['diff'] = differences.get_legacy_docker_diffs()
            self.diff_tracker.merge(differences)

        if not self.check_mode and not self.parameters.debug:
            self.results.pop('actions')