Показаны сообщения с ярлыком ansible. Показать все сообщения
Показаны сообщения с ярлыком ansible. Показать все сообщения

четверг, 29 сентября 2016 г.

Ansible change line in file on remote hosts


  If you want to change some line in some file (for exampe it would be /etc/environment and line that beginning from JAVA_HOME  ) on group of hosts with ansible you should use the next playbook:

---
- hosts: PCPool
  sudo: yes
  tasks:

    - name: Change line
      lineinfile: dest=/etc/environment regexp='^JAVA_HOME' line=JAVA_HOME="/usr/lib/jvm/java-8-oracle"


where hosts - group of hosts from ansible file hosts
          ineinfile - module of ansible

and in console you should use the next command:

 ansible-playbook change_line.yml -k --user=USER --ask-sudo-pass


if you want to chek the results:

ansible PCPool -u agent -k -m shell -a 'less /etc/invironment'