Package: ansible-aisnippet
ansible-aisnippetFeaturesQuickstartInstall python packageInstall the latest versionansible-aisnippetwithpiporpipxpipinstallansible-aisnippetUsageYou must have an openai.api_key. You can create it fromopenaiwebsite.exportOPENAI_KEY=<yourtoken>

ansible-aisnippet--helpUsage:ansible-aisnippet[OPTIONS]COMMAND[ARGS]...

╭─Options─────────────────────────────────────────────────────╮
│--version-vShowtheapplication's│
│versionandexit.│
│--install-completionInstallcompletionforthe│
│currentshell.│
│--show-completionShowcompletionforthe│
│currentshell,tocopyitor│
│customizetheinstallation.│
│--helpShowthismessageandexit.│
╰───────────────────────────────────────────────────────────────╯
╭─Commands────────────────────────────────────────────────────╮
│generateAskChatGPTtowriteanansibletaskusinga│
│template│
╰───────────────────────────────────────────────────────────────╯Generate task(s)ansible-aisnippet can generate an or several ansible task from a description or
a filetasks.ansible-aisnippetgenerate--helpUsage:ansible-aisnippetgenerate[OPTIONS][TEXT]AskChatGPTtowriteanansibletaskusingatemplate

╭─Arguments──────────────────────────────────────────────────────────────────────╮
│text[TEXT]Adescriptionoftasktoget[default:Installpackagehtop]│
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─Options────────────────────────────────────────────────────────────────────────╮
│--verbose-vverbosemode│
│--filetasks-fPATH[default:None]│
│--outputfile-oPATH[default:None]│
│--playbook-pCreateaplaybook│
│--helpShowthismessageandexit.│
╰──────────────────────────────────────────────────────────────────────────────────╯Generate a taskexportOPENAI_KEY=<yourtoken>

ansible-aisnippetgenerate"execute command to start /opt/application/start.sh create /var/run/test.lock"Buildingprefixdictfromthedefaultdictionary...
Loadingmodelfromcache/tmp/jieba.cache
Loadingmodelcost0.686seconds.
Prefixdicthasbeenbuiltsuccessfully.
name:Executecommandtostart/opt/application/start.shcreate/var/run/test.lock

ansible.builtin.command:chdir:/opt/applicationcmd:./start.sh&&touch/var/run/test.lockcreates:/var/run/test.lockremoves:''Generate severals tasksansible-aisnippet can generate severals tasks from a file. The file is a yaml file which contains a list of tasks and blocksEx:-task:Install package htop, nginx and net-tools with generic module-task:Copy file from local file /tmp/toto to remote /tmp/titi set mode 0666 owner bob group wwwregister:test-name:A blockwhen:test.rc == 0block:-task:wait for port 6300 on localhost timeout 25rescue:-task:Execute command /opt/application/start.sh creates /var/run/test.lock-task:Download file from https://tmp.io/test/ set mode 0640 and force trueThis file produces this result :exportOPENAI_KEY=<yourtoken>

ansible-aisnippetgenerate-ftest.yml-p
Buildingprefixdictfromthedefaultdictionary...
Loadingmodelfromcache/tmp/jieba.cache
Loadingmodelcost0.671seconds.
Prefixdicthasbeenbuiltsuccessfully.
Result:

-name:Playbookgeneratedwithchatgpthosts:allgather_facts:truetasks:-name:Installpackagehtop,nginxandnet-toolsansible.builtin.yum:name:-htop-nginx-net-toolsstate:present-name:Copyfilefromlocalfile/tmp/tototoremote/tmp/titiansible.builtin.copy:src:/tmp/totodest:/tmp/titimode:'0666'owner:bobgroup:wwwregister:test-name:Ablockwhen:test.rc==0block:-name:Waitforport6300onlocalhosttimeout25ansible.builtin.wait_for:host:127.0.0.1port:'6300'timeout:'25'rescue:-name:Executecommand/opt/application/start.shcreates/var/run/test.lockansible.builtin.command:chdir:/tmp/testcmd:/opt/application/start.shcreates:/var/run/test.lock-name:Downloadfilefromhttps://tmp.io/test/ansible.builtin.get_url:backup:falsedecompress:truedest:/tmp/testforce:truegroup:rootmode:'0640'owner:roottimeout:'10'tmp_dest:/tmp/testurl:https://tmp.io/test/validate_certs:true