title: Using chown command in ansible?
body: <p>I have a command in ubuntu as </p>
  
  <pre><code>  sudo chown $(id -u):$(id -g) $HOME/.kube/config 
  </code></pre>
  
  <p>I want to convert into ansible script. I have tried below </p>
  
  <pre><code>- name: Changing ownership
        command: chown $(id -u):$(id -g) $HOME/.kube/config
        become: true 
  </code></pre>
  
  <p>but i am getting error as below </p>
  
  <blockquote>
    <p>fatal: [ubuntu]: FAILED! => {"changed": t> fatal: [ubuntu]: FAILED! => {"changed": true, "cmd": ["chown", "$(id",
    "-u):$(id", "-g)", "$HOME/.kube/config"], "delta": "0:00:00.003948",
    "end": "2019-07-17 07:22:31.798773", "msg": "non-zero return code",
    "rc": 1, "start": "2019-07-17 07:22:31.794825", "stderr": "chown:
    invalid option -- 'u'\nTry 'chown --help' for more information.",
    "stderr_lines": ["chown: invalid option -- 'u'", "Try 'chown --help'
    for more information."], "stdout": "", "stdout_lines": []}rue, "cmd": ["chown", "$(id",
    "-u):$(id", "-g)", "$HOME/.kube/config"], "delta": "0:00:00.003948",
    "end": "2019-07-17 07:22:31.798773", "msg": "non-zero return code",
    "rc": 1, "start": "2019-07-17 07:22:31.794825", "stderr": "chown:
    invalid option -- 'u'\nTry 'chown --help' for more information.",
    "stderr_lines": ["chown: invalid option -- 'u'", "Try 'chown --help'
    for more information."], "stdout": "", "stdout_lines": []}</p>
  </blockquote>
  
  <p><strong>EDIT:</strong>
  File module also did not work.</p>
  
  <pre><code>  - name: Create a symbolic link
      file:
        path: $HOME/.kube
        owner: $(id -u)
        group: $(id -g)
  </code></pre>