This commit is contained in:
mwiegand 2021-06-20 21:18:53 +02:00
parent fb0234bf3a
commit b4ea5849f5
3 changed files with 27 additions and 9 deletions

View file

@ -88,7 +88,7 @@ actions['install_nextcloud'] = {
data_dir=node.metadata.get('nextcloud/data_dir'),
),
'unless': """
psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='users' AND table_schema='public'" | grep -q "^OK$"
psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='oc_users' AND table_schema='public'" | grep -q "^OK$"
""",
'needs': [
'postgres_db:nextcloud',
@ -125,9 +125,9 @@ files['/opt/nextcloud/config/config.php'] = {
actions['upgrade_nextcloud'] = {
'command': occ('upgrade'),
'unless': occ('status') + ' | grep -q "installed: true"',
'needs': [
'file:/opt/nextcloud/config/config.php',
'triggered': True,
'triggered_by': [
f'action:extract_nextcloud',
],
}

View file

@ -1,3 +1,6 @@
import string
from uuid import UUID
defaults = {
'apt': {
'packages': {
@ -28,7 +31,6 @@ defaults = {
},
},
'nextcloud': {
'instance_id': 'oc3wqc1kg39w',
'data_dir': '/var/lib/nextcloud',
'admin_user': 'admin',
'admin_pass': repo.vault.password_for(f'{node.name} nextcloud admin pw'),
@ -54,3 +56,18 @@ defaults = {
},
},
}
@metadata_reactor.provides(
'nextcloud/instance_id',
)
def instance_id(metadata):
return {
'nextcloud': {
'instance_id': repo.libs.derive_string.derive_string(
UUID(metadata.get('id')).bytes,
length=12,
choices=(string.ascii_lowercase + string.digits).encode(),
).decode(),
},
}

View file

@ -62,9 +62,10 @@ def chacha_chracter(input, choices):
def derive_string(input, length, choices):
get_character = chacha_chracter(input, choices)
sorted_choices = bytes(sorted(choices))
get_character = chacha_chracter(input, sorted_choices)
return bytes(islice(get_character, length))
print(
derive_string(b'12344', length=100, choices=b'abcdefghijklmnopqrstuvwxyz0123456789')
)
# print(
# derive_string(b'12344', length=100, choices=b'abcdefghijklmnopqrstuvwxyz0123456789')
# )