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:

  1. wait till rpm installed , "running"
  2. stop service
  3. modify configuration file somehow? use when clause limit group want modify.
  4. 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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -