1

Hi I am having a task which is as follows

   - name: Replace log directory in configuration
      lineinfile:
        path: $HOME/amsible_test/test.txt
        regexp: '^dataDir='
        line: 'dataDir=$HOME/.zookeeper_log'  

it's running fine , But issue is that this is writing line as dataDir=$HOME/.zookeeper_log

but as per my understanding it should parse $HOME as /home/username as per ubuntu 16.04 .It should write dataDir=/home/username/.zookeeper.log but not doing as expected.

any suggestion what i am doing wrong . I tried many alternate for string parsing purpose but no luck.

Thanks in advance

Pankaj Cheema
  • 1,028
  • 2
  • 13
  • 26

1 Answers1

1

Hi this worked for me ..

- name: test connection
  shell: echo $HOME
  register: user_home

- name: Replace log directory in configuration

  lineinfile:
    path: $HOME/amsible_test/test.txt
    regexp: '^dataDir='
    line: 'dataDir={{user_home.stdout}}/.zookeeper_log'
Pankaj Cheema
  • 1,028
  • 2
  • 13
  • 26