Questions tagged [yaml]
YaML is a human-readable data serialisation format.
102
questions
8
votes
2
answers
14k
views
quoting colon in ansible
I am trying to use ansible to check that the output of a particular program is set to a certain value. That value includes a colon followed by a space, and this seems to register as a syntax error no ...
7
votes
3
answers
82k
views
Get current hostname and push it into conf file with ansible
I'm working into an ansible playbook to get the current hostname of a server and then set it into a configuration file. I cannot figure it out how can I push the shell output using the lineinfile ...
6
votes
2
answers
11k
views
How to merge variables of type hash across different variable files in ansible?
I have two YAML variable files which are reused for many playbooks:
# playbook/group_vars/all
settings:
a: 1
b: 2
# inventory/group_vars/main.yml
settings:
c: 3
I want settings to be equal {...
6
votes
1
answer
9k
views
Adding an existing security group CloudFormation EC2 template
Instead of having to set ingress and egress rules, how do I reference existing EC2 security groups in a CloudFormation Template?
Resources:
EC2Instance:
Type: AWS::EC2::Instance
...
6
votes
2
answers
6k
views
Is it possible to change the current user's password in-band with ansible?
I have a Linux distribution that is freshly installed. It has a regular user with a default password, and a locked down root account (no password on root - can't be SSHed as directly). I want to be ...
5
votes
1
answer
163
views
Why do some r10k configuration files start their YAML lines with :?
I'm looking at setting up r10k for Puppet deployment, and I have various example r10k.yaml configuration files, but some seem to use an extra : at the start of many lines, for instance, at http://www....
4
votes
3
answers
48k
views
Ansible check if variable exists in attribute list
I have a variable containing details of host machines on my network (called 'hostlist' - I believe you call this a dictionary, but I'm not sure of the terminology. The variable is defined in a file in ...
4
votes
1
answer
2k
views
Verifying Salt states before committing
I'm storing my salt sls files in a git repository, but I have the perennial problem that I can't verify my YAML represents a valid set of states that could be applied (I've also had difficulty ...
3
votes
2
answers
454
views
How does the formatting policy look like since Ansible 2.0?
I have seen multiple Ansible examples on github and in the ansible docs, e.g.:
---
# this might be in a file like handlers/handlers.yml
- name: restart apache
service: name=apache state=restarted
...
3
votes
1
answer
6k
views
How to define multiple /etc/hosts entries with Puppet ENC?
I'm writing an External Node Classifier for my Puppet infrastructure, and I have the need to manipulate the /etc/hosts file on each node. The following (due to the duplicate key) is invalid YAML:
---
...
3
votes
1
answer
3k
views
Contents in Kubernetes pod gets empty when persistent volume is mounted
persistent volume claim and persistent volume yaml file
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
...
3
votes
1
answer
4k
views
dict as value for YAML key in an Ansible task
I am unable to figure out how to pass a dictionary/hash-map of key-value pairs as the value for an option in an ansible tasks.
Default Options:
# roles/ec2/defaults/main.yml
ec2:
key_name: "{{ ...
3
votes
2
answers
12k
views
How to pass a group value in inventory file to jinja2 template file in ansible
I have an inventory file named hospital.inventory and it contains following group with a single value.
[dockerSwarmManager]
hp2-3.mydomain.com
Then I have a file name security.json.j2 inside the ...
3
votes
1
answer
3k
views
Cross-reference Ansible variables within the same mapping
How can I define an Ansible variable whose value is another variable in the same mapping structure?
To allow sensible namespacing of variables, I am defining mapping structures like this, where some ...
3
votes
1
answer
1k
views
Configure AWS CloudFront to send custom query params to origin
Is it possible to configure my AWS CloudFront distribution to append to the request a custom query param (e.g a private key) before sending it to the origin?
For example, the front end is calling *....
3
votes
1
answer
11k
views
Problems with setting up bonding on Netplan (Ubuntu server 18.04)
I have a dual port network card that I want to bond both ports and balance the traffic between ports. I want 1 static IP address. I used to ubuntu 16.04 and this worked fine. Im now trying to set ...
2
votes
2
answers
3k
views
SaltStack: found conflicting ID
My sls file:
/etc/sudoers.d/foo:
file.managed:
- contents: |
foo ALL = NOPASSWD: /usr/bin/systemctl restart minio_storage-foo.service
foo ALL = NOPASSWD: /bin/systemctl restart ...
2
votes
1
answer
3k
views
How to validate variables contents in Ansible?
ansible-lint only checks the tasks/handlers and doesn't iterate over the variables (e.g. if you're using with_items, it won't iterate over all the items) and yamllint only checks cosmetic issues and ...
2
votes
1
answer
16k
views
How to use Ansible modules replace or inline instead shell command with SED
i have file with string:
MYAPP.db.username.DEV=MYUSERNAME
Where:
MYAPP mean name of applications
DEV means environment
MYUSERNAME means name of user for connection to db
I need to replace these ...
2
votes
1
answer
472
views
Create JSON Patch 6902 from two yaml/json files
Imagine I have a file foo.yaml and a modified version of this file called foo2.yaml.
Is there a way to create a correspondig json patch 6902?
2
votes
1
answer
10k
views
Use lookup/dynamic variable names in Ansible jinja2 template
The playbook below should generate a file with the content:
a,b
ssh_host_key
ssh_rsa_host_key
However, the way I construct the variable names results in either syntax/templating errors or 'variable ...
2
votes
1
answer
2k
views
Templated dict keys in ansible YAML
I am trying to use a dict in an Ansible task, which is defined like this:
in vars/main.yml file:
username: user1
userpass: pass1
users:
"{{ username }}":
pass: "{{ userpass }}"
This doesn't ...
2
votes
1
answer
2k
views
How can I enable epel-release before installing packages with cloud-init?
I'm trying to install a few packages on CentOS 8 via cloud-init, like this:
package_upgrade: true
packages:
- firewalld
- htop
One of them one of them requires epel-release repo to be installed ...
2
votes
1
answer
9k
views
Ansible error: The tasks/main.yml file for role 'common' must contain a list of tasks
I inherited this ansible git from my predecessor. I can't get it to work though and I guess it's something basic that I'm missing. It keeps giving me this lovely error: ERROR! The tasks/main.yml file ...
2
votes
1
answer
1k
views
Unable to delete daemonSet in k8s
I've created a daemonSet in k8s under the namespace kube-system.
While trying to delete the deamonSet it got stuck (also when I force it)
I've already tried to set a updateStrategy: RollingUpdate To ...
2
votes
1
answer
3k
views
patroni.exceptions.PatroniFatalException: 'Failed to bootstrap cluster'
I have a problem with patroni right here
[postgres@localhost ~]$ patroni /etc/patroni.yml
2021-05-25 11:39:56,767 INFO: Selected new etcd server http://10.102.196.138:2379
2021-05-25 11:39:56,772 INFO:...
2
votes
1
answer
1k
views
AWS CloudFormation - Creating Layer Version and Function that uses layer
I have a Cloudformation template that currently looks roughly like the following.
Resources:
MyLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- nodejs12....
2
votes
0
answers
153
views
Puppet - Get interface name from netplan yaml config
How to get interface name which has nameservers defined?
I want to get the interface name so I can pass it to another netplan puppet module so the nameservers can be replaced. But I only want to get ...
1
vote
1
answer
3k
views
CloudFormation template: how to use Sub and GetAtt at the same time in short form?
I'm using yaml. So, we can use either:
!GetAtt [ WebServer, AvailabilityZone ]
!GetAtt WebServer.AvailabilityZone
Also, we can use:
!Sub 'sometext-${AWS::StackName}'
how can I use GetAtt output ...
1
vote
1
answer
5k
views
How to use vars in ansible roles
I want to create a ansible role to add user with ssh_keys
├── ansible.cfg
├── hosts
├── playbooks
│ └── add_user.yml
└── roles
└── add-user
├── files
│ ├── ansible.pub
...
1
vote
1
answer
3k
views
CloudFormation stack yaml syntax?
I'm trying to create a SecurityGroup which has a tag like Name: SG-StackName. This code works perfect in json:
"Resources": {
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
...
1
vote
1
answer
1k
views
How do I loop over items 1 by 1 in Ansible config (YAML/Jinja2)?
I am trying to loop over my hosts from my inventory in Ansible, and use the name of the host of that iteration in a command. In particular, I am trying to set the hostname of each of my hosts to ...
1
vote
1
answer
865
views
Commands not working “with_item” in ansible playbook
I am new to ansible and trying to write a basic playbook for mongodb backup with simplest method. here is what i am trying to do:
---
- hosts: mongo
tasks:
- name: Mongo Dump
command: ...
1
vote
3
answers
2k
views
Can you set the number of rounds that ansible's password_hash jinja2 filter uses?
In ansible, it's pretty convenient to use something like this:
- name: Make sure user password is set
user:
name: my_user
password: "{{ user_password|password_hash('sha512', 'SomeSalt') }}"...
1
vote
1
answer
5k
views
Alertmanager telegram config chat_id and cannot unmarshal errror
I am trying to configure alertmanager to send alerts to my telegram group. Following the configuration I have:
global:
resolve_timeout: 5m
route:
group_by:
- job
group_interval: 5m
...
1
vote
1
answer
5k
views
Ansible expect is not sending response
I'm new to ansible and trying it by writing an ansible playbook for installing graphite, as a part of it I have the graphite-manage syncdb command which I would like to automate.
I wrote this task to ...
1
vote
1
answer
3k
views
saltstack configuration "No Top file or external nodes data matches found"
A very similar version of this question is asked here , but it's completely different since the person had their top file in the wrong directory.
I have 3 projects, that I'll call project1, ...
1
vote
1
answer
52
views
I am getting an error in the ansible playbook file
I am trying to learn ansible and I have coded my first playbook but it gives me the error saying
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: ...
1
vote
2
answers
246
views
How to use wget with headers in liveness probe in a yaml file in kubernetes?
I am trying to use wget in my liveness probe in Kubernetes. Here is the code:
apiVersion: v1
kind: Pod
metadata:
namespace: test
labels:
test: liveness
name: liveness-exec
spec:
containers:...
1
vote
1
answer
1k
views
replace with regular expression in azure devops
I want to take this buildVariable
Build.SourceVersion
which will equal for example:
0gc58d92d905d62415b8866g3f48f17416da426s
And replace from digit [7] till line end with empty string
0gc58d92
I ...
1
vote
1
answer
1k
views
Password of new user with LXD and Cloud-init
I'm trying to create a profile to automate the creation of a container, but I'm having trouble with cloud-init. For some reason the password is not being set for the user and is also not being added ...
1
vote
1
answer
2k
views
How to convert and save raw data to PDF format using ansible
I will be getting some raw data directly from an API. I want to format this and convert into PDF file and save it. I gone through ansible modules. I am not getting any idea in this. Can someone ...
1
vote
1
answer
1k
views
Create a tree-like structure with ansible
I have to create an LDAP structure with users and groups.
The groups are a bit complex with a lot of nested groups etc. I need to create a tree like structure in my inventory, like the following:
---...
1
vote
1
answer
2k
views
pod's name from an environment variables defined in yaml
how can I create a yaml file for pod that get its name from a environment variables defined in yaml file.
I have tried this but it is not allowed.
metadata:
generateName: $(HOSTNAME)
.
.
.
env:
...
1
vote
1
answer
513
views
Puppet parse hiera in inline_template
I have got some .yaml hiera file with:
iptables::test:
ip:
1.1.1.1 : 'adm-1'
2.2.2.2 : 'adm-2'
3.3.3.3 : 'adm-3'
And i want to parse this file in inline_template. I write:
$...
1
vote
1
answer
423
views
Gitlab CI/CD with conditional scripts
Here is what I wish to do in GitLab CI/CD:
Whenever something is pushed into a specific branch I wish to have multiple scrips and CI/CD should decide which script should be run based on the pushed ...
1
vote
1
answer
130
views
"Report-To" HTTP header implementation for GAE Standard
I'm attempting to add a "Report-To:" HTTP header to our App Engine's app.yaml configuration file for integration with https://report-uri.com (based on the Reporting API here, here, and here) but when ...
1
vote
1
answer
1k
views
app.yaml isn't updated when I deploy (Google App engine/Google Cloud Platform)
This is my default app.yaml file:
runtime: custom
env: flex
service: api
runtime_config:
jdk: openjdk8
handlers:
- url: /.*
script: this field is required, but ignored
automatic_scaling:
...
1
vote
1
answer
1k
views
Saltstack for firewalld
I am trying to get a state set up so that I can add the associated ports open in firewalld.
Tried every example I can find and all fail.
Here is my current:
firewalld:
service.running:
- ...
1
vote
1
answer
5k
views
How can I install Development Tools via vagrant and ansible on Centos 6.7
I get this error when running my first ansible playbook (i.e. I am not familiar with ansible yet)
TASK: [Install packages] ******************************************************
failed: [default] =&...