S
S
Sergei Sakharov2021-10-12 17:54:18
OpenBSD
Sergei Sakharov, 2021-10-12 17:54:18

How to write a playbook that not only installs software, but also writes config and starts services?

6165a2f97ee0e349926000.pngI want to run ansible-playbook web-up.yml and have the web server up and running immediately.
I want to run ansible-playbook web-down.yml and have the webserver down immediately and the packages removed.
I want to run ansible-playbook dns-up.yml and have the DNS server up and running immediately.
and so on...
I also want to be able to run several roles on hosts at once.
What means to edit rc.conf for editing the pkg_script variable?
well, there are little things - creating / deleting the conf.d folder in /etc/nginx and transferring the php settings from the sample folder to the working one.
While there is an idea to write scripts for each configuration, and in playbooks only copy and execute script files, but how much is this consistent with working practice? I'm just starting to learn ansible, is this approach justified? Up to storing information about the current configuration in the database and generating configuration files based on it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MaxKozlov, 2021-10-12
@Afranius

to install/remove software - pkg/apt/yum module, etc.
To create/raise/lower/delete services - service or systemd
for conf - template, files+state: link
And for scripts ansible is not needed. Enough ssh

P
Puma Thailand, 2021-10-13
@opium

Damn dude, would you at least read some kind of brochure ansible for idiots for a start, I’m generally silent about the documentation, it’s right on the level, but how to write?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question