Skip to content

Commit

Permalink
Merge pull request #18 from p3lim/hostrecord
Browse files Browse the repository at this point in the history
Add support for enrolling host with DNS records
  • Loading branch information
fpytloun authored Aug 31, 2021
2 parents 2570140 + d78f81f commit 2a75304
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion freeipa/client/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,54 @@ freeipa_get_ticket:
- file: freeipa_push_principal
- onchanges:
- file: freeipa_push_principal
{%- if client.ip is defined %}
{%- set client_ip = client.get("ip") %}
freeipa_dnsrecord_add:
cmd.run:
- name: >
curl -k -s
-H referer:https://{{ ipa_servers[0] }}/ipa
--negotiate -u :
-H "Content-Type:application/json"
-H "Accept:application/json"
-c /tmp/cookiejar -b /tmp/cookiejar
--output /dev/stderr
--write-out "%{http_code}"
-X POST
-d '{
"id": 0,
"method": "dnsrecord_add",
"params": [
[
"{{ client.get("domain", {}) }}",
{
"__dns_name__": "{{ client.get("hostname", {}).replace(client.get("domain", {}), "")[:-1] }}"
}
],
{
{%- if client_ip.get("reverse", True) %}
{%- if client_ip.get("aaaa") %}
"aaaa_extra_create_reverse": true,
{%- else %}
"a_extra_create_reverse": true,
{%- endif %}
{%- endif %}
{%- if client_ip.get("aaaa") %}
"aaaa_part_ip_address": "{{ client_ip.get("aaaa") }}",
{%- else %}
"a_part_ip_address": "{{ client_ip.get("a", salt.grains.get("fqdn_ip4", [])[0]) }}",
{%- endif %}
"version": "2.156"
}
]
}' https://{{ ipa_servers[0] }}/ipa/json | awk '{if ($0<200||$0>399) exit $0}'
- require:
- cmd: freeipa_get_ticket
- require_in:
- cmd: freeipa_client_install
- onchanges:
- file: freeipa_push_principal
{%- endif %}
freeipa_host_add:
cmd.run:
- name: >
Expand All @@ -34,6 +82,8 @@ freeipa_host_add:
-H "Content-Type:application/json"
-H "Accept:applicaton/json"
-c /tmp/cookiejar -b /tmp/cookiejar
--output /dev/stderr
--write-out "%{http_code}"
-X POST
-d '{
"id": 0,
Expand All @@ -53,9 +103,12 @@ freeipa_host_add:
"version": "2.156"
}
]
}' https://{{ ipa_servers[0] }}/ipa/json
}' https://{{ ipa_servers[0] }}/ipa/json | awk '{if ($0<200||$0>399) exit $0}'
- require:
- cmd: freeipa_get_ticket
{%- if client.ip is defined %}
- cmd: freeipa_dnsrecord_add
{%- endif %}
- require_in:
- cmd: freeipa_client_install
- onchanges:
Expand Down

0 comments on commit 2a75304

Please sign in to comment.