I will be getting some raw data directly from an API. I want to format this and convert into PDF file and save it. I gone through ansible modules. I am not getting any idea in this. Can someone suggest how we can achieve it using Ansible please.
-
2Ansible is a configuration management and orchestration tool, not a text formatter. Use a correct tool for the job. – Michael Hampton Sep 17 '20 at 11:59
-
Actually, There is some dependancy on that file for the oncoming tasks in the playbook. We can convert that data using Python also. But just want to know, whether we can do the same using Ansible or not? – saffron Sep 17 '20 at 14:41
-
1You can run any command you want, but you still need to have a tool that converts text to PDF. – Michael Hampton Sep 17 '20 at 14:43
1 Answers
When I asume you want to use Ansible to create the PDF from scratch you have several options:
The best one - you create your own Ansible-Python-Module (see https://medium.com/@auscunningham/write-a-ansible-module-with-python-527f0b292b4d) and integrate it some Python-Libraries (https://realpython.com/creating-modifying-pdf/). After that you can use the newly created python-module inside your playbooks or roles. It depends on your input (structured data) that need to be send to the module during execution.
Another option is to use some command line tools to create a PDF from some source code (like LateX can do). So you install LateX (just as an example), create a text file (with template-module) and run a command to create the PDF based on the template.
Both works.
- 438
- 3
- 14