Creating automations using Ansible

Hi all,

I need to create automations via Ansible. I appreciate that this is perhaps an unusual request, but I want to automate my automations! Turtles all the way down…

As far as I can see, the only way to do this currently is via the RESTful API using a POST, is that correct? What is the recommended way to create/update automations using Ansible?

I have also posted about this in the Development channel but no reply as yet.

Thus far, I have been able to create a text helper using Ansible, but not an automation. As mentioned in my other post, my POST request gets a 405.


I generate most of my automations and packages vis configuration generators. So if you a trying to automate config generation this is a good approach. Break up your config into packages and then build it from whatever tool you want (I use shell scripts and YQ).

My main problem at the moment is that when I try to create an automation via the REST API it returns “HTTP Error 405: Method Not Allowed”. Not sure what I’m doing wrong but would appreciate any suggestions.

I am also open to directly adding files to the automations directory, however I guess that this would need me to SSH into the home assistant box. As I am running HAOS on my own server, I am not sure how to do this.

Do you send a long lived token with your HTTP request?

Yes. If I were not, would it return 403 instead?