WillyXJ / facileManager

A modular suite of web apps built with the sysadmin in mind.
www.facilemanager.com
GNU General Public License v2.0
85 stars 37 forks source link

[HELP] Programatically create records #579

Closed lravelo closed 10 months ago

lravelo commented 1 year ago

I need a way to programmatically create records (using Ansible in my particular case but looking to start small and build from there). I was looking into #510 and am wondering if there's any way this could be done via CLI from the server. I did see it mentioned that the reloads needed to happen via the GUI but I'm sure there's some php function that could be called via CLI to perform the same thing? Worst case maybe using something like Selenium to automate that last step?

Looking forward to some feedback

WillyXJ commented 1 year ago

Right now the API is only supported on the client. Frankly it needs to be rewritten. You can always directly inject your records into the database using SQL statements.

lravelo commented 1 year ago

Ok so this means I would need to run the same command on all of my DNS servers to create the record and then from there reload via the master server, correct?

Any decent example that you could provide would be extremely helpful (I.e., a SQL command that would create the record and reload all of the applicable zones or any other method I could use to get this done strictly via CLI)

Thanks!

WillyXJ commented 1 year ago

You don’t need to run the same command on every server — just from one to manage the records in the database.

Then I think you can run the client.php -z id=XX on each dns server.

lravelo commented 1 year ago

You don’t need to run the same command on every server — just from one to manage the records in the database.

Then I think you can run the client.php -z id=XX on each dns server.

So I'm trying this and am seeing an issue. Hopefully it's something wrong with my command. I'm running the following:

php /usr/local/facileManager/fmDNS/client.php  setHost id=4 action=add type=A name=test value=x.x.x.x ttl=1800 createPTR=yes comment="testing API" status=active

It does create the record in the forward zone but it doesn't create the associated PTR record (I didn't see any mention of createPTR in client.php -h so not sure if this actually does anything or it I will have to manually create the PTR record.

WillyXJ commented 1 year ago

The API support with fmDNS v5.3.3 does not support automatic PTR creation.