diff --git a/apps/accounts/automations/verify_account/host/windows/main.yml b/apps/accounts/automations/verify_account/host/windows/main.yml index da9d40a74..6e126f34d 100644 --- a/apps/accounts/automations/verify_account/host/windows/main.yml +++ b/apps/accounts/automations/verify_account/host/windows/main.yml @@ -1,5 +1,5 @@ - hosts: windows - gather_facts: yes + gather_facts: no tasks: - name: Verify account ansible.windows.win_ping: diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 36dff55a9..579da474d 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -17,15 +17,14 @@ class AccountSerializerCreateValidateMixin: replace_attrs: callable def to_internal_value(self, data): - self.id = data.pop('id', None) + _id = data.pop('id', None) ret = super().to_internal_value(data) - self.push_now = ret.pop('push_now', False) - self.template = ret.pop('template', False) + self.id = _id return ret def set_secret(self, attrs): _id = self.id - template = self.template + template = attrs.pop('template', None) if _id and template: account_template = AccountTemplate.objects.get(id=_id) @@ -33,14 +32,16 @@ class AccountSerializerCreateValidateMixin: elif _id and not template: account = Account.objects.get(id=_id) attrs['secret'] = account.secret + return attrs def validate(self, attrs): - self.set_secret(attrs) - return super().validate(attrs) + attrs = super().validate(attrs) + return self.set_secret(attrs) def create(self, validated_data): + push_now = validated_data.pop('push_now', None) instance = super().create(validated_data) - if self.push_now: + if push_now: push_accounts_to_assets.delay([instance.id], [instance.asset_id]) return instance diff --git a/apps/assets/automations/gather_facts/host/posix/main.yml b/apps/assets/automations/gather_facts/host/posix/main.yml index 81aef9aac..89c412f57 100644 --- a/apps/assets/automations/gather_facts/host/posix/main.yml +++ b/apps/assets/automations/gather_facts/host/posix/main.yml @@ -4,16 +4,21 @@ - name: Get info ansible.builtin.set_fact: info: - arch: "{{ ansible_architecture }}" - distribution: "{{ ansible_distribution }}" - distribution_version: "{{ ansible_distribution_version }}" - kernel: "{{ ansible_kernel }}" vendor: "{{ ansible_system_vendor }}" model: "{{ ansible_product_name }}" sn: "{{ ansible_product_serial }}" + cpu_model: "{{ ansible_processor }}" + cpu_count: "{{ ansible_processor_count }}" + cpu_cores: "{{ ansible_processor_cores }}" cpu_vcpus: "{{ ansible_processor_vcpus }}" memory: "{{ ansible_memtotal_mb }}" disk_total: "{{ (ansible_mounts | map(attribute='size_total') | sum / 1024 / 1024 / 1024) | round(2) }}" + distribution: "{{ ansible_distribution }}" + distribution_version: "{{ ansible_distribution_version }}" + arch: "{{ ansible_architecture }}" + kernel: "{{ ansible_kernel }}" + + - debug: var: info diff --git a/apps/assets/serializers/asset/host.py b/apps/assets/serializers/asset/host.py index e01e1bab9..dd8d3bc2f 100644 --- a/apps/assets/serializers/asset/host.py +++ b/apps/assets/serializers/asset/host.py @@ -19,13 +19,10 @@ class HostInfoSerializer(serializers.Serializer): cpu_vcpus = serializers.IntegerField(required=False, label=_('CPU vcpus')) memory = serializers.CharField(max_length=64, allow_blank=True, required=False, label=_('Memory')) disk_total = serializers.CharField(max_length=1024, allow_blank=True, required=False, label=_('Disk total')) - disk_info = serializers.CharField(max_length=1024, allow_blank=True, required=False, label=_('Disk info')) - os = serializers.CharField(max_length=128, allow_blank=True, required=False, label=_('OS')) - os_version = serializers.CharField(max_length=16, allow_blank=True, required=False, label=_('OS version')) - os_arch = serializers.CharField(max_length=16, allow_blank=True, required=False, label=_('OS arch')) - hostname_raw = serializers.CharField(max_length=128, allow_blank=True, required=False, label=_('Hostname raw')) - number = serializers.CharField(max_length=128, allow_blank=True, required=False, label=_('Asset number')) + distribution = serializers.CharField(max_length=128, allow_blank=True, required=False, label=_('OS')) + distribution_version = serializers.CharField(max_length=16, allow_blank=True, required=False, label=_('OS version')) + arch = serializers.CharField(max_length=16, allow_blank=True, required=False, label=_('OS arch')) class HostSerializer(AssetSerializer):