pref: 添加 deploy playbook

pull/8991/head
ibuler 2022-10-26 17:21:52 +08:00
parent e327c97170
commit 99e4836311
11 changed files with 831 additions and 569 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:ab1c609cc4c83a223835be0eab2a5a5b9050c853b66ccd2b2fa480073c8fc763 oid sha256:5d945fc6151d6f6354052a0a09706a52e7a2fa2f9e02254965cf26b134d78c3a
size 103346 size 103377

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
# Generated by Django 3.2.14 on 2022-10-26 09:07
from django.db import migrations, models
def update_builtin_org(apps, schema_editor):
org_model = apps.get_model('orgs', 'Organization')
org_model.objects.create(
id='00000000-0000-0000-0000-000000000004',
name='SYSTEM', builtin=True
)
# 更新 Default
org_model.objects.filter(name='DEFAULT').update(builtin=True)
class Migration(migrations.Migration):
dependencies = [
('orgs', '0013_alter_organization_options'),
]
operations = [
migrations.AddField(
model_name='organization',
name='builtin',
field=models.BooleanField(default=False, verbose_name='Builtin'),
),
migrations.RunPython(update_builtin_org),
]

View File

@ -69,6 +69,7 @@ class Organization(OrgRoleMixin, models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True) id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=128, unique=True, verbose_name=_("Name")) name = models.CharField(max_length=128, unique=True, verbose_name=_("Name"))
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by')) created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
builtin = models.BooleanField(default=False, verbose_name=_('Builtin'))
date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name=_('Date created')) date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name=_('Date created'))
comment = models.TextField(default='', blank=True, verbose_name=_('Comment')) comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))
members = models.ManyToManyField( members = models.ManyToManyField(
@ -139,13 +140,13 @@ class Organization(OrgRoleMixin, models.Model):
@classmethod @classmethod
def default(cls): def default(cls):
defaults = dict(id=cls.DEFAULT_ID, name=cls.DEFAULT_NAME) defaults = dict(id=cls.DEFAULT_ID, name=cls.DEFAULT_NAME)
obj, created = cls.objects.get_or_create(defaults=defaults, id=cls.DEFAULT_ID) obj, created = cls.objects.get_or_create(defaults=defaults, id=cls.DEFAULT_ID, builtin=True)
return obj return obj
@classmethod @classmethod
def root(cls): def root(cls):
name = settings.GLOBAL_ORG_DISPLAY_NAME or cls.ROOT_NAME name = settings.GLOBAL_ORG_DISPLAY_NAME or cls.ROOT_NAME
return cls(id=cls.ROOT_ID, name=name) return cls(id=cls.ROOT_ID, name=name, builtin=True)
def is_root(self): def is_root(self):
return self.id == self.ROOT_ID return self.id == self.ROOT_ID

View File

@ -4,6 +4,7 @@ import threading
from collections import defaultdict from collections import defaultdict
from functools import partial from functools import partial
import django.db.utils
from django.dispatch import receiver from django.dispatch import receiver
from django.conf import settings from django.conf import settings
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
@ -45,7 +46,10 @@ def expire_orgs_mapping_for_memory(org_id):
def subscribe_orgs_mapping_expire(sender, **kwargs): def subscribe_orgs_mapping_expire(sender, **kwargs):
logger.debug("Start subscribe for expire orgs mapping from memory") logger.debug("Start subscribe for expire orgs mapping from memory")
if settings.DEBUG: if settings.DEBUG:
try:
set_to_default_org() set_to_default_org()
except django.db.utils.OperationalError:
pass
def keep_subscribe_org_mapping(): def keep_subscribe_org_mapping():
orgs_mapping_for_memory_pub_sub.subscribe( orgs_mapping_for_memory_pub_sub.subscribe(

View File

View File

@ -0,0 +1,56 @@
---
- hosts: windows
vars:
- DownloadHost: https://demo.jumpserver.org/download
- RDS_Licensing: enabled
- RDS_LicenseServer: 127.0.0.1
- RDS_LicensingMode: 4
- RDS_fSingleSessionPerUser: 0
- RDS_MaxDisconnectionTime: 60000
- RDS_RemoteAppLogoffTimeLimit: 0
tasks:
- name: Install RDS-Licensing (RDS)
ansible.windows.win_feature:
name: RDS-Licensing
state: present
include_management_tools: yes
when: RDS_Licensing == "enabled"
- name: Install RDS-RD-Server (RDS)
ansible.windows.win_feature:
name: RDS-RD-Server
state: present
include_management_tools: yes
register: win_feature
- name: Reboot if installing RDS feature requires it
ansible.windows.win_reboot:
when: win_feature.reboot_required
- name: Set RDS LicenseServer (regedit)
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: LicenseServers
data: "{{ RDS_LicenseServer }}"
type: string
- name: Set RDS LicensingMode (regedit)
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: LicensingMode
data: "{{ RDS_LicensingMode }}"
type: dword
- name: Set RDS fSingleSessionPerUser (regedit)
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: fSingleSessionPerUser
data: "{{ RDS_fSingleSessionPerUser }}"
type: dword
- name: Set RDS MaxDisconnectionTime (regedit)
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: MaxDisconnectionTime
data: "{{ RDS_MaxDisconnectionTime }}"
type: dword
when: RDS_MaxDisconnectionTime >= 60000
- name: Set RDS RemoteAppLogoffTimeLimit (regedit)
ansible.windows.win_regedit:
path: HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
name: RemoteAppLogoffTimeLimit
data: "{{ RDS_RemoteAppLogoffTime }}"

View File

@ -0,0 +1,26 @@
# Generated by Django 3.2.14 on 2022-10-26 08:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('terminal', '0054_auto_20221024_1452'),
]
operations = [
migrations.RemoveField(
model_name='applet',
name='vcs_type',
),
migrations.RemoveField(
model_name='applet',
name='vcs_url',
),
migrations.AddField(
model_name='applet',
name='is_active',
field=models.BooleanField(default=True, verbose_name='Is active'),
),
]

View File

@ -27,8 +27,7 @@ class Applet(JMSBaseModel):
version = models.CharField(max_length=16, verbose_name=_('Version')) version = models.CharField(max_length=16, verbose_name=_('Version'))
author = models.CharField(max_length=128, verbose_name=_('Author')) author = models.CharField(max_length=128, verbose_name=_('Author'))
type = models.CharField(max_length=16, verbose_name=_('Type'), default='general', choices=Type.choices) type = models.CharField(max_length=16, verbose_name=_('Type'), default='general', choices=Type.choices)
vcs_type = models.CharField(max_length=16, verbose_name=_('VCS type'), null=True) is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
vcs_url = models.CharField(max_length=256, verbose_name=_('URL'), null=True)
protocols = models.JSONField(default=list, verbose_name=_('Protocol')) protocols = models.JSONField(default=list, verbose_name=_('Protocol'))
tags = models.JSONField(default=list, verbose_name=_('Tags')) tags = models.JSONField(default=list, verbose_name=_('Tags'))
comment = models.TextField(default='', blank=True, verbose_name=_('Comment')) comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))