-1

I am new to ansible.
I have about 50 servers where I have to change a username and password in the file /etc/nova/nova.conf

Line: 3102 OS_USERNAME = ABC123 (OLD)  
Line: 3103 OS_PASSWORD = xxXXxx (OLD)  

with new credentials

Line: 3102 OS_USERNAME = DEF123 (NEW)  
Line: 3103 OS_PASSWORD = vvVVvv (NEW)  
tlo
  • 1,571
  • 1
  • 25
  • 38
  • 1
    Hi Muzzamil, welcome to SO. Your question is not clear on what you are trying to achieve, what is actually happening and what you tried. Please read [**how to ask**](https://stackoverflow.com/help/how-to-ask) and [**how to create a minimum, reproducible example**](https://stackoverflow.com/help/minimal-reproducible-example) for better results when using the site. Good luck! – kenny_k Sep 30 '19 at 20:28

1 Answers1

0

I'd use the lineinfile module. For your example above:

- name: Update username in nova.conf
  lineinfile:
    path: /etc/nova/nova.conf
    regexp: '^OS_USERNAME'
    line: OS_USERNAME = DEF123
Mark Loeser
  • 17,657
  • 2
  • 26
  • 34