YAML snippets reference in Deploy
This reference includes some useful snippets to get started when writing DevOps as Code YAML files that can be applied to Deploy.
This section includes some useful snippets to get started when writing YAML files to apply to Deploy.
Create infrastructure
Use the Infrastructure
kind to set up servers and cloud/container endpoints. You can specify a list of servers in the spec
section.
apiVersion: xl-deploy/v1
kind: Infrastructure
spec:
- name: Infrastructure/Apache host
type: overthere.SshHost
os: UNIX
address: tomcat-host.local
username: tomcatuser
- name: Infrastructure/local-docker
type: docker.Engine
dockerHost: http://dockerproxy:2375
- name: aws
type: aws.Cloud
accesskey: YOUR ACCESS KEY
accessSecret: YOUR SECRET
Create environments with dictionary
Create environments and dictionaries:
apiVersion: xl-deploy/v1
kind: Environments
spec:
- name: AWS Dictionary
type: udm.Dictionary
entries:
region: eu-west-1
username: aws-user
- name: AWS
type: udm.Environment
members:
- ~Infrastructure/aws
dictionaries:
- ~Environments/AWS Dictionary
Create a deployment package with an artifact
Create a deployment package for a war file:
apiVersion: xl-deploy/v1
kind: Applications
spec:
- name: Applications/MyApp
type: udm.Application
lastVersion: "1.0"
children:
- name: "1.0"
type: udm.DeploymentPackage
deployables:
- name: Server
type: jee.War
file: !file server.war
Group multiple YAML files
Group YAML files for sequential execution:
apiVersion: xl/v1
kind: Import
metadata:
imports:
- create/create-homes.yaml
- create/create-files.yaml
- create/create-docker.yaml
- create/create-k8s.yaml
Define home directories
Use -home
to indicate home directories:
apiVersion: xl-deploy/v1
kind: Environments
metadata:
Environments-home: Environments/XL
Configuration-home: Configuration/XL
Infrastructure-home: Infrastructure/XL
spec:
- directory: k8s
children:
- name: Local
type: udm.Environment
triggers:
- ~Configuration/t1
- Configuration/XL/t2
members:
- ~Infrastructure/k8s/Minukube/default
dictionaries:
- ../../dict2
- name: dict
type: udm.Dictionary
entries:
user: admin
password: qwerty
encryptedEntries:
user: admin
password: qwerty
- name: dict2
type: udm.Dictionary
Permissions
You can specify permissions-related details in YAML. This section includes YAML snippets for users, roles and global permissions.
Users
Create new users and passwords:
---
apiVersion: xl-deploy/v1
kind: Users
spec:
- username: admin
- username: chris_smith
- password: !value pass1
- username: jay_albert
- password: test
- username: sue_perez
- password: test
Roles
Create roles (Leaders
and Developers
) and assign users to each role:
---
apiVersion: xl-deploy/v1
kind: Roles
spec:
- name: Leaders
principals:
- jay_albert
- name: Developers
principals:
- ron_vallee
- sue_perez
Global permissions
Assign global permissions to roles:
---
apiVersion: xl-deploy/v1
kind: Permissions
spec:
- directory: Applications/docker
roles:
- role: Leaders
permissions:
- controltask#execute
- role: Developers
permissions:
- controltask#execute
- generate#dsl
- deploy#initial
- global:
- role: Leaders
permissions:
- report#view
- task#assign
- role: Developers
permissions:
- task#skip_step
- admin
- login
- task#takeover
- task#preview_step
- report#view
- discovery
- controltask#execute
- task#assign
- task#view
- task#move_step
- security#edit
Start a deployment
Start a deployment using the Deployment
kind:
---
apiVersion: xl-deploy/v1
kind: Deployment
spec:
package: Applications/XL/cmd/AppWithCommands/1.0
environment: Environments/XL/Production
orchestrators:
- parallel-by-deployment-group
- sequential-by-container
Source tag for adding file values to a property
The !source tag followed by a file path takes the contents of a file in the specified location and adds it as the value of a property in the form of a string. This can be useful for example if you have a long description which is more convenient to store in an external file, or if you want to store a script separately and add it to a property such as a script action. If the file cannot be found, it will return an error.
apiVersion: xl-release/v1
kind: Templates
spec:
- directory: AsCode
children:
- template: As Code child release
description: !source text/description.md
variables:
- type: xlrelease.StringVariable
key: version
label: release version
description: this variable contains the version of the release
phases:
- phase: Child release phase 1
tasks:
- scripty
type: xlrelease.GroovyScriptTask
owner: admin
script: !source script/some_script.py