I have a yaml file which includes key value. How do i upload it into etcd?
tech:
corev2uat:
"#services":
pms:
multifirm:
environment: true
Related
I am trying to create a configuration file in GCP Deployment Manager and i have a metadata file which needs to imported as text.
I know on how do it in .py file, but wondering on how to do it in YAML.
I tried different but none seem to work.
Although Deployment Manager can use the imports statement to import Jinja2 or Python templates into the root configuration file, plain YAML cannot be imported. This is limitation of YAML. It does not have "import" or "include" functionality.
A similar question has been discussed here: https://stackoverflow.com/a/15437697/11602913.
In a pure YAML deployment file, metadata can be provided literally, as described in the document
Google Cloud Platform for AWS Professionals: Infrastructure Deployment Tools:
resources:
- name: my-first-vm-template
type: compute.v1.instance
properties:
...
metadata:
items:
- key: startup-script
value: "STARTUP-SCRIPT-CONTENTS"
If metadata should be loaded from a file, you have to use Jinja2 templates. There is an example at codelabs.developers.google.com:
Deploy Your Infrastructure Using Deployment Manager > Creating your deployment configuration
imports:
- path: instance.jinja
- path: ../startup-script.sh
name: startup-script.sh
resources:
- name: my-instance
type: instance.jinja
properties:
metadata-from-file:
startup-script: startup-script.sh
https://cloud.google.com/deployment-manager/docs/configuration/templates/create-basic-template
I can deploy a template directly like this: gcloud deployment-manager deployments create a-single-vm --template vm_template.jinja
But what if that template depends on other files that need to be imported? If using a --config file you can define import in that file and call the template as a resource. But you cant pass parameter/properties to a config file. I want to call a template directly to pass --properties via the command line but that template also needs to import other files.
EDIT: What I needed was a top level jinja template instead of a config. My confusion was that you cant use imports in a jinja template without a schema file- it was failing and I thought it wasnt supported. So the solution was just swap out the config with a jinja template (with schema file) and then I can use --properies
Maybe you can try importing the dependent files into your config file as follows:
imports:
- path: vm-template.jinja
- path: vm-template-2.jinja
# In the resources section below, the properties of the resources are replaced
# with the names of the templates.
resources:
- name: vm-1
type: vm-template.jinja
- name: vm-2
type: vm-template-2.jinja
and Set Arbitrary Metadata insito create a special variable that you can pass and might use in other applications outside of Deployment Manager:
properties:
size:
type: integer
default: 2
description: Number of Mongo Slaves
variable-x: ultra-secret-sauce
More info about gcloud deployment-manager deployments create optional flags and example can be found here.
More info about passing properties using a Schema can be found here
Hope it helps
I have a password ending in a colon, say abc:, that I want to store encrypted in GIT and decrypt with Spring Cloud Config.
Here's the expected YAML file :
spring:
datasource:
password: "abc:"
Here's the encrypted YAML file :
spring:
datasource:
password: "{cipher}blablabla"
And here's what I receive from Spring Cloud Config after decryption :
spring:
datasource:
password: abc:
Which is interpreted as a key instead of a value by the YAML parser.
Is there a way to tell Spring Cloud Config that I want to surround the decrypted value in quotes or something similar ?
EDIT
My mistake, Spring Could Config server actually adds quotes when needed after decrypting the string. So the result is as expected :
spring:
datasource:
password: 'abc:'
The issue is that when I reference this value using a placeholder the quotes disappear in the process :
a_key:
another_key: ${spring.datasource.password}
becomes when processed by Spring Could Config server :
a_key:
another_key: abc:
So the question really is : how to preserve quotes when referencing a value using placeholders in a YAML file with Spring Cloud Config?
The only way I found so far is to leave the placeholder resolution to runtime by escaping the $ character :
a_key:
another_key: \${spring.datasource.password}
The resulting YAML served by Spring Cloud Config server is then :
a_key:
another_key: ${spring.datasource.password}
Link to Spring Cloud Config documentation here
I am using the AzureFileCopy task to copy files to a blob for a cdn, but all my new files end up as application/octet-stream by default. Is there any way this can be changed?
steps:
- task: AzureFileCopy#1
displayName: ' File Copy - blob'
inputs:
SourcePath: '$(System.DefaultWorkingDirectory)/xxxxxx/blob'
azureSubscription: 'xxxxxx'
Destination: AzureBlob
storage: xxxxxx
ContainerName: cdn
When upgrading to the latest task version (V5), Azure File Copy will set the content types by default for destination type Blob.
AzCopy sets the content type for a blob or file to application/octet-stream by default. You can set the content type for all blobs or files by explicitly specifying a value for this option.
If you specify this option without a value, then AzCopy sets each blob or file's content type according to its file extension. You can refer to https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy#setcontenttypecontent-type for more details.
I am using Grails 3 Elasticsearch plugin with Springs external JSON configuration by setting spring.application.json as system property.
The properties are available in the application but I can't find a way to initialize an array properly.
What I am trying to accomplish is to override the default values of the hosts property specified in my application.yml:
environments:
development:
elasticSearch:
client:
hosts:
- {host: "myhost.com", port: 9300}
- {host: "anotherhost.com", port: 9300}
I am setting the property from the command line as follows:
-Dspring.application.json={"environments":{"development":{"elasticSearch":{"client":{"hosts":[{"host":"override1.com", "port":9000},{"host":"override2.com", "port":9100}]}}}}}
I would expect environments.development.elasticSearch.client.hosts to contain an array like it does when initialized from the application.yml, but in fact environments.development.elasticSearch.client containes host[0] and host[1], where each contains the host and the port. The host array from the yml file is still there.
How can I achieve the same behavior using the command line as with the application.yml file?
I believe you can do this the same way that you would if it was set in a .properties file, using a list:
-Denvironments.developmet.elasticSearch.client.hosts={"host":"override1.com", "port":9000},{"host":"override2.com", "port":9100}
and I believe you can also do it as an environment variable...
set ENVIRONMENTS_DEVELOPMENT_ELASTICSEARCH_CLIENT_HOSTS='{"host":"override1.com", "port":9000},{"host":"override2.com", "port":9100}'
There may need to be some quotes around parts of these depending on the shell you are in, the OS, etc.