title: Install Docker on RHEL VM using ansible
body: <p>I want to install Docker CE from binaries on a remote RHEL VM using Ansible. I've followed steps mentioned in <a href="https://docs.docker.com/install/linux/docker-ce/binaries/#prerequisites" rel="nofollow noreferrer">guide</a> and made a playbook. I skipped the optional third step because I'm using full path to the executable. However, when my script gets to the step 4 - starting the Docker daemon, it does not start. </p>
  
  <p>The debug output I see is: </p>
  
  <pre><code>TASK [Debug] *********************************************************************************************************************************************************************************************************************************
  ok: [10.230.166.49] =&gt; {
  "tmp": {
      "changed": true, 
      "cmd": "sudo /root/docker/dockerd &amp;", 
      "delta": "0:00:00.025462", 
      "end": "2018-02-16 22:26:58.213010", 
      "failed": false, 
      "rc": 0, 
      "start": "2018-02-16 22:26:58.187548", 
      "stderr": "time=\"2018-02-16T22:26:58.211441819-05:00\" level=warning msg=\"could not change group /var/run/docker.sock to docker: group docker not found\"\nFailed to connect to containerd: exec: \"docker-containerd\": executable file not found in $PATH", 
      "stderr_lines": [
          "time=\"2018-02-16T22:26:58.211441819-05:00\" level=warning msg=\"could not change group /var/run/docker.sock to docker: group docker not found\"", 
          "Failed to connect to containerd: exec: \"docker-containerd\": executable file not found in $PATH"
      ], 
      "stdout": "", 
      "stdout_lines": [], 
      "warnings": [
          "Consider using 'become', 'become_method', and 'become_user' rather than running sudo"
      ]
  } }
  </code></pre>
  
  <p>Here is my Ansible playbook: </p>
  
  <pre><code>---
   - hosts: remotes
     become: yes
     tasks:
      - name: Fetch docker version
        shell: docker version 2&gt;&amp;1 | grep Version | awk '{print $2}'
        register: docker_version 
  
      - name: Check if docker is installed, download binary otherwise
        command: curl -O https://download.docker.com/linux/static/stable/x86_64/docker-17.12.0-ce.tgz
        when: docker_version.stdout == ''
  
      - name: Extract binary
        unarchive: 
          src: /root/docker-17.12.0-ce.tgz
          dest: /root/
          remote_src: yes
        when: docker_version.stdout == ''
  
      - name: start docker
        shell: sudo /root/docker/dockerd &amp;
        register: tmp
  
      - name: Debug
        debug: 
          var: tmp
  </code></pre>
  
  <p>On a side note, I logged onto remote VM and ran </p>
  
  <pre><code>ls -al docker
  </code></pre>
  
  <p>and found that directory docker that I get after the binary's been extracted belongs to a group vradeploy. Here's the output :</p>
  
  <pre><code>total 107112
  drwxr-xr-x  2 root vradeploy     4096 Dec 27 15:13 .
  dr-xr-x---. 7 root root          4096 Feb 16 20:53 ..    
  -rwxr-xr-x  1 root vradeploy 19938610 Dec 27 15:13 docker
  -rwxr-xr-x  1 root vradeploy 15433832 Dec 27 15:13 docker-containerd
  -rwxr-xr-x  1 root vradeploy 12773768 Dec 27 15:13 docker-containerd-ctr
  -rwxr-xr-x  1 root vradeploy  4320064 Dec 27 15:13 docker-containerd-shim
  -rwxr-xr-x  1 root vradeploy 46366152 Dec 27 15:13 dockerd
  -rwxr-xr-x  1 root vradeploy   760040 Dec 27 15:13 docker-init
  -rwxr-xr-x  1 root vradeploy  2517244 Dec 27 15:13 docker-proxy
  -rwxr-xr-x  1 root vradeploy  7550928 Dec 27 15:13 docker-runc
  </code></pre>