configuration - Ansible modifying files after RPM installation -
as part of ansible playbook down , install rpm internal repository. rpm comes packaged bunch of configuration. of machines don't need change configuration. small subset, defined ansible group, need modify few of configuration fields.
i'm assuming need so:
- wait till rpm installed , "running"
- stop service
- modify configuration file somehow? use when clause limit group want modify.
- restart service
or possibly there better way achieve this. can out there suggest how achieve general goal?
your 4 step procedure looks me. perhaps service doesn't have stopped before modifying configuration.
i'd create ansible role necessary tasks defined. base structure role created ansible-galaxy init command.
ansible-galaxy init my_role the configuration file can modified (or rather generated) using ansible's template module:
- name: modify configuration file template: src=myconf.cnf.j2 dest=/etc/myconf.cnf when: "'my_group_name' in group_names" notify: restart service it run hosts belong my_group_name group. template myconf.cnf.j2 has found my_role/templates directory. service restarted when restart service handler notified in task. handler needs put my_role/handlers/main.yml file:
- name: restart service service: name=service_name state=restarted
Comments
Post a Comment