#ansible - July 2020

ansibleArchived
5 messages

Discussions related to ansible configuration management

Saichovsky
Saichovskyover 6 years ago
Hey,

I have a playbook that installs the datadog agent on remote hosts using the datadog.datadog module and then proceeds to carry out a number of tasks, such as configuring some tools and having datadog read logs from the tools. I would like for my playbook to restart the datadog agent after making the changes (adjusting read permissions on the logs so the agent is able to read the log files)
Saichovsky
Saichovskyover 6 years ago
I use notify: restart datadog-agent to restart the agent, but I don’t think that it is working. The restart datadog-agent handler is not defined in my playbook, but it is a part of the datadog.datadog module. My question is: how to I invoke a handler defined in a module that I am importing in my playbook (if using notify is not the way to go)?
Brij S
Brij Sover 6 years ago
Hey all, trying to create some route53 records. As per the ansible docs, you can pass in a comma delimited string to value . I’m trying the following
- name: Create Route53 record
  route53:
    state: present
    zone: "{{ item.domain }}{{ tld }}"
    record: "{{ aws_account_name }}.{{ item.domain }}{{ tld }}"
    overwrite: True
    type: NS
    ttl: "172800"
    aws_access_key: "{{ assumed_role.sts_creds.access_key }}"
    aws_secret_key: "{{ assumed_role.sts_creds.secret_key }}"
    security_token: "{{ assumed_role.sts_creds.session_token }}"
    value: "{{ item.resource_records }}"
  with_items:
    - { resource_records: "route53_zone_info | json_query('results[0].ResourceRecordSets[0].ResourceRecords[].Value') | join(',')", domain: "{{ domains[0] }}" }
    - { resource_records: "route53_zone_info | json_query('results[1].ResourceRecordSets[0].ResourceRecords[].Value') | join(',')", domain: "{{ domains[1] }}" }

but then I get the following error:
failed: [localhost] (item={'resource_records': "route53_zone_info | json_query('results[0].ResourceRecordSets[0].ResourceRecords[].Value') | join(',')", 'domain': 'lllapps'}) => {"ansible_loop_var": "item", "changed": false, "item": {"domain": "lllapps", "resource_records": "route53_zone_info | json_query('results[0].ResourceRecordSets[0].ResourceRecords[].Value') | join(',')"}, "msg": "[Invalid Resource Record: FATAL problem: RRDATANotSingleField (Value contains spaces) encountered with 'route53_zone_info | json_query('results[0].ResourceRecordSets[0].ResourceRecords[].Value') | join('']"}
Brij S
Brij Sover 6 years ago
the value should not contain any spaces 🤔 the output is as follows
"route53_zone_info | json_query('results[1].ResourceRecordSets[0].ResourceRecords[].Value') | join(',')": "ns-1111.11111.,ns-111111.co.uk.,1111111.awsdns-48.net.,ns11111.awsdns-51.com."
}
Brij S
Brij Sover 6 years ago
any idea whats wrong?