Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ansible vars file #2115

Merged
merged 41 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1e1d7b5
:wrench: Add URLs for Gitea and Hedgedoc
jemrobinson Aug 6, 2024
d4593ed
:sparkles: Add desktop files and icons for gitea and hedgedoc
jemrobinson Aug 6, 2024
9fc781b
:sparkles: Add desktop icons for input, output and shared folders
jemrobinson Aug 6, 2024
6d0da02
Move icons to /usr/local/share
JimMadge Aug 7, 2024
484d68c
WIP: write vars from pulumi to desired state
JimMadge Aug 8, 2024
1f6c0b9
Move desired state to new component
JimMadge Aug 8, 2024
3f285ea
Correct hostname arguments
JimMadge Aug 8, 2024
384e955
Correct subnet variable names
JimMadge Aug 8, 2024
d5d0768
Update NSG names
JimMadge Aug 8, 2024
3766790
Correct IP range name
JimMadge Aug 9, 2024
dbccff7
Fix IP ranges test
JimMadge Aug 9, 2024
7a41029
Move ansible vars file function
JimMadge Aug 9, 2024
7686234
Merge remote-tracking branch 'origin/develop' into ansible_vars_file
JimMadge Aug 13, 2024
5c193fe
Use string asset for blob
JimMadge Aug 13, 2024
d5920c8
Apply StringAsset to str not Output[str]
JimMadge Aug 13, 2024
b0febc7
Add StringAsset to typings
JimMadge Aug 13, 2024
9b48edb
Correct cloudinit template argument name
JimMadge Aug 13, 2024
56d4e8a
:bug: Ensure that icons directory is created
jemrobinson Aug 12, 2024
913ccd0
:recycle: Simplify ansible setup by copying all files in a directory …
jemrobinson Aug 12, 2024
7eb8317
:wrench: Do not create xrdp directories separately
jemrobinson Aug 12, 2024
d5fc6b7
Tidy ansible
JimMadge Aug 13, 2024
57b8d14
Remove unused notify
JimMadge Aug 13, 2024
3e1eb30
Correct template argument
JimMadge Aug 13, 2024
c67fe5b
Use vars file in desired state play
JimMadge Aug 13, 2024
9427541
Correct desktop file name
JimMadge Aug 13, 2024
546764e
Wait for clamd.ctl to be created
JimMadge Aug 8, 2024
3fcc1ae
Restart clamd when configuration is updated
JimMadge Aug 8, 2024
3edb214
Correct socket file name
JimMadge Aug 8, 2024
626be80
Move cloud init template to ansible
JimMadge Aug 13, 2024
8720a3e
Update data_safe_haven/infrastructure/common/ip_ranges.py
JimMadge Sep 2, 2024
f23a8c8
Merge remote-tracking branch 'origin/develop' into ansible_vars_file
JimMadge Sep 2, 2024
96fb551
Correct ip range test
JimMadge Sep 2, 2024
908f608
Merge remote-tracking branch 'origin/develop' into ansible_vars_file
JimMadge Sep 17, 2024
ab5e710
Merge branch 'mount_points' into ansible_vars_file
JimMadge Sep 17, 2024
22c754f
Add NFSV3StorageAccount component
JimMadge Sep 17, 2024
435697b
Add composite resource for NFS blob containers
JimMadge Sep 17, 2024
2bae206
Correct path to install_deb script
JimMadge Sep 17, 2024
cb89697
Correct paths in comments
JimMadge Sep 17, 2024
aa46d23
Update pulumi component properties
JimMadge Sep 17, 2024
d62c0cc
Correct template names
JimMadge Sep 18, 2024
9e6b1b9
Rename class
JimMadge Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data_safe_haven/infrastructure/common/ip_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SREIpRanges:
apt_proxy_server = vnet.next_subnet(8)
clamav_mirror = vnet.next_subnet(8)
data_configuration = vnet.next_subnet(8)
data_desired_state = vnet.next_subnet(8)
data_private = vnet.next_subnet(8)
desired_state = vnet.next_subnet(8)
firewall = vnet.next_subnet(64) # 64 address minimum
firewall_management = vnet.next_subnet(64) # 64 address minimum
guacamole_containers = vnet.next_subnet(8)
Expand Down
6 changes: 6 additions & 0 deletions data_safe_haven/infrastructure/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
LocalDnsRecordProps,
MicrosoftSQLDatabaseComponent,
MicrosoftSQLDatabaseProps,
NFSV3BlobContainerComponent,
NFSV3BlobContainerProps,
PostgresqlDatabaseComponent,
PostgresqlDatabaseProps,
VMComponent,
Expand All @@ -19,6 +21,7 @@
SSLCertificateProps,
)
from .wrapped import (
NFSV3StorageAccount,
WrappedLogAnalyticsWorkspace,
)

Expand All @@ -34,6 +37,9 @@
"LocalDnsRecordProps",
"MicrosoftSQLDatabaseComponent",
"MicrosoftSQLDatabaseProps",
"NFSV3BlobContainerComponent",
"NFSV3BlobContainerProps",
"NFSV3StorageAccount",
"PostgresqlDatabaseComponent",
"PostgresqlDatabaseProps",
"SSLCertificate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
MicrosoftSQLDatabaseComponent,
MicrosoftSQLDatabaseProps,
)
from .nfsv3_blob_container import NFSV3BlobContainerComponent, NFSV3BlobContainerProps
from .postgresql_database import PostgresqlDatabaseComponent, PostgresqlDatabaseProps
from .virtual_machine import LinuxVMComponentProps, VMComponent

Expand All @@ -12,6 +13,8 @@
"LocalDnsRecordProps",
"MicrosoftSQLDatabaseComponent",
"MicrosoftSQLDatabaseProps",
"NFSV3BlobContainerComponent",
"NFSV3BlobContainerProps",
"PostgresqlDatabaseComponent",
"PostgresqlDatabaseProps",
"VMComponent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from pulumi import ComponentResource, Input, ResourceOptions
from pulumi_azure_native import storage

from data_safe_haven.infrastructure.components.dynamic.blob_container_acl import (
BlobContainerAcl,
BlobContainerAclProps,
)


class NFSV3BlobContainerProps:
def __init__(
self,
acl_user: Input[str],
acl_group: Input[str],
acl_other: Input[str],
apply_default_permissions: Input[bool],
container_name: Input[str],
resource_group_name: Input[str],
storage_account: Input[storage.StorageAccount],
subscription_name: Input[str],
):
self.acl_user = acl_user
self.acl_group = acl_group
self.acl_other = acl_other
self.apply_default_permissions = apply_default_permissions
self.container_name = container_name
self.resource_group_name = resource_group_name
self.storage_account = storage_account
self.subscription_name = subscription_name


class NFSV3BlobContainerComponent(ComponentResource):
def __init__(
self,
name: str,
props: NFSV3BlobContainerProps,
opts: ResourceOptions | None = None,
):
super().__init__("dsh:common:NFSV3BlobContainerComponent", name, {}, opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

storage_container = storage.BlobContainer(
f"{self._name}_blob_container_{props.container_name}",
account_name=props.storage_account.name,
container_name=props.container_name,
default_encryption_scope="$account-encryption-key",
deny_encryption_scope_override=False,
public_access=storage.PublicAccess.NONE,
resource_group_name=props.resource_group_name,
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(parent=props.storage_account),
),
)
BlobContainerAcl(
f"{storage_container._name}_acl",
BlobContainerAclProps(
acl_user=props.acl_user,
acl_group=props.acl_group,
acl_other=props.acl_other,
apply_default_permissions=props.apply_default_permissions,
container_name=storage_container.name,
resource_group_name=props.resource_group_name,
storage_account_name=props.storage_account.name,
subscription_name=props.subscription_name,
),
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(parent=props.storage_account),
),
)

self.name = storage_container.name

self.register_outputs({})
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .log_analytics_workspace import WrappedLogAnalyticsWorkspace
from .nfsv3_storage_account import NFSV3StorageAccount

__all__ = [
"NFSV3StorageAccount",
"WrappedLogAnalyticsWorkspace",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from collections.abc import Mapping, Sequence

from pulumi import Input, Output, ResourceOptions
from pulumi_azure_native import storage

from data_safe_haven.external import AzureIPv4Range


class NFSV3StorageAccount(storage.StorageAccount):
JimMadge marked this conversation as resolved.
Show resolved Hide resolved
encryption_args = storage.EncryptionArgs(
JimMadge marked this conversation as resolved.
Show resolved Hide resolved
key_source=storage.KeySource.MICROSOFT_STORAGE,
services=storage.EncryptionServicesArgs(
blob=storage.EncryptionServiceArgs(
enabled=True, key_type=storage.KeyType.ACCOUNT
),
file=storage.EncryptionServiceArgs(
enabled=True, key_type=storage.KeyType.ACCOUNT
),
),
)

def __init__(
self,
resource_name: str,
*,
account_name: Input[str],
allowed_ip_addresses: Input[Sequence[str]],
location: Input[str],
resource_group_name: Input[str],
subnet_id: Input[str],
opts: ResourceOptions,
tags: Input[Mapping[str, Input[str]]],
):
self.resource_group_name_ = Output.from_input(resource_group_name)
super().__init__(
resource_name,
account_name=account_name,
enable_https_traffic_only=True,
enable_nfs_v3=True,
encryption=self.encryption_args,
is_hns_enabled=True,
kind=storage.Kind.BLOCK_BLOB_STORAGE,
location=location,
minimum_tls_version=storage.MinimumTlsVersion.TLS1_2,
network_rule_set=storage.NetworkRuleSetArgs(
bypass=storage.Bypass.AZURE_SERVICES,
default_action=storage.DefaultAction.DENY,
ip_rules=Output.from_input(allowed_ip_addresses).apply(
lambda ip_ranges: [
storage.IPRuleArgs(
action=storage.Action.ALLOW,
i_p_address_or_range=str(ip_address),
)
for ip_range in sorted(ip_ranges)
for ip_address in AzureIPv4Range.from_cidr(ip_range).all_ips()
]
),
virtual_network_rules=[
storage.VirtualNetworkRuleArgs(
virtual_network_resource_id=subnet_id,
)
],
),
resource_group_name=resource_group_name,
sku=storage.SkuArgs(name=storage.SkuName.PREMIUM_ZRS),
opts=opts,
tags=tags,
)
36 changes: 25 additions & 11 deletions data_safe_haven/infrastructure/programs/declarative_sre.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .sre.backup import SREBackupComponent, SREBackupProps
from .sre.clamav_mirror import SREClamAVMirrorComponent, SREClamAVMirrorProps
from .sre.data import SREDataComponent, SREDataProps
from .sre.desired_state import SREDesiredStateComponent, SREDesiredStateProps
from .sre.dns_server import SREDnsServerComponent, SREDnsServerProps
from .sre.firewall import SREFirewallComponent, SREFirewallProps
from .sre.identity import SREIdentityComponent, SREIdentityProps
Expand Down Expand Up @@ -184,7 +185,6 @@ def __call__(self) -> None:
storage_quota_gb_home=self.config.sre.storage_quota_gb.home,
storage_quota_gb_shared=self.config.sre.storage_quota_gb.shared,
subnet_data_configuration=networking.subnet_data_configuration,
subnet_data_desired_state=networking.subnet_data_desired_state,
subnet_data_private=networking.subnet_data_private,
subscription_id=self.config.azure.subscription_id,
subscription_name=self.context.subscription_name,
Expand Down Expand Up @@ -338,17 +338,15 @@ def __call__(self) -> None:
tags=self.tags,
)

# Deploy workspaces
workspaces = SREWorkspacesComponent(
"sre_workspaces",
# Deploy desired state
desired_state = SREDesiredStateComponent(
"sre_desired_state",
self.stack_name,
SREWorkspacesProps(
admin_password=data.password_workspace_admin,
apt_proxy_server_hostname=apt_proxy_server.hostname,
SREDesiredStateProps(
admin_ip_addresses=self.config.sre.admin_ip_addresses,
clamav_mirror_hostname=clamav_mirror.hostname,
data_collection_rule_id=monitoring.data_collection_rule_vms.id,
data_collection_endpoint_id=monitoring.data_collection_endpoint.id,
database_service_admin_password=data.password_database_service_admin,
dns_private_zones=dns.private_zones,
gitea_hostname=user_services.gitea_server.hostname,
hedgedoc_hostname=user_services.hedgedoc_server.hostname,
ldap_group_filter=ldap_group_filter,
Expand All @@ -358,11 +356,27 @@ def __call__(self) -> None:
ldap_user_filter=ldap_user_filter,
ldap_user_search_base=ldap_user_search_base,
location=self.config.azure.location,
resource_group=resource_group,
software_repository_hostname=user_services.software_repositories.hostname,
subnet_desired_state=networking.subnet_desired_state,
subscription_name=self.context.subscription_name,
),
)

# Deploy workspaces
workspaces = SREWorkspacesComponent(
"sre_workspaces",
self.stack_name,
SREWorkspacesProps(
admin_password=data.password_workspace_admin,
apt_proxy_server_hostname=apt_proxy_server.hostname,
data_collection_rule_id=monitoring.data_collection_rule_vms.id,
data_collection_endpoint_id=monitoring.data_collection_endpoint.id,
location=self.config.azure.location,
maintenance_configuration_id=monitoring.maintenance_configuration.id,
resource_group_name=resource_group.name,
software_repository_hostname=user_services.software_repositories.hostname,
sre_name=self.config.name,
storage_account_data_desired_state_name=data.storage_account_data_desired_state_name,
storage_account_desired_state_name=desired_state.storage_account_name,
storage_account_data_private_user_name=data.storage_account_data_private_user_name,
storage_account_data_private_sensitive_name=data.storage_account_data_private_sensitive_name,
subnet_workspaces=networking.subnet_workspaces,
Expand Down
Loading
Loading