<p dir="auto">I'm using ansible-pull as cron.daily job for syncing new packages to my clients.<br>
But right now it fails to pull updates from the remote host.<br>
I run ansible-pull like this:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#!/bin/bash
# Cron job to git clone/pull a repo and then run locally
echo &quot;127.0.0.1&quot; &gt; /tmp/ansible_hosts
su root -c 'env ANSIBLE_HOSTS=&quot;/tmp/ansible_hosts&quot; ansible-pull -d /var/lib/ansible/local -U ansible-git:ansible -C ansible-update &gt;/var/log/ansible-pull.log 2&gt;&amp;1'"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#!</span>/bin/bash</span>
<span class="pl-c"><span class="pl-c">#</span> Cron job to git clone/pull a repo and then run locally</span>
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>127.0.0.1<span class="pl-pds">"</span></span> <span class="pl-k">&gt;</span> /tmp/ansible_hosts
su root -c <span class="pl-s"><span class="pl-pds">'</span>env ANSIBLE_HOSTS="/tmp/ansible_hosts" ansible-pull -d /var/lib/ansible/local -U ansible-git:ansible -C ansible-update &gt;/var/log/ansible-pull.log 2&gt;&amp;1<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">ansible-git is defind in my ssh_config. The Output from ansible-pull is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="127.0.0.1 | success &gt;&gt; {
    &quot;after&quot;: &quot;971fe17&quot;, 
    &quot;before&quot;: &quot;971fe17&quot;, 
    &quot;changed&quot;: false
}"><pre class="notranslate"><code class="notranslate">127.0.0.1 | success &gt;&gt; {
    "after": "971fe17", 
    "before": "971fe17", 
    "changed": false
}
</code></pre></div>
<p dir="auto">But git status shows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="~# git status
# On branch ansible-update
# Your branch is behind 'origin/ansible-update' by 3 commits, and can be fast-forwarded.
#
nothing to commit (working directory clean)"><pre class="notranslate"><code class="notranslate">~# git status
# On branch ansible-update
# Your branch is behind 'origin/ansible-update' by 3 commits, and can be fast-forwarded.
#
nothing to commit (working directory clean)
</code></pre></div>
<p dir="auto">When using a non-cloned (originally) repository, the git module errors out.</p>
<p dir="auto">The logic here:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cmd = &quot;git branch -a&quot;
cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(gbranch_out, gbranch_err) = cmd.communicate()

try:
   m = re.search( '^\* (\S+|\(no branch\))$', gbranch_out, flags=re.M )
   cur_branch = m.group(1)
   m = re.search( '\s+remotes/origin/HEAD -&gt; origin/(\S+)', gbranch_out, flags=re.M )
   default_branch = m.group(1)"><pre class="notranslate"><code class="notranslate">cmd = "git branch -a"
cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(gbranch_out, gbranch_err) = cmd.communicate()

try:
   m = re.search( '^\* (\S+|\(no branch\))$', gbranch_out, flags=re.M )
   cur_branch = m.group(1)
   m = re.search( '\s+remotes/origin/HEAD -&gt; origin/(\S+)', gbranch_out, flags=re.M )
   default_branch = m.group(1)
</code></pre></div>
<p dir="auto">Seems to be the culprit.</p>
<p dir="auto">There is most likely a different way to determine the default branch. Something like git ls-remotes? or the like?</p>
<p dir="auto">Currently there are two possible work-arounds:</p>
<ol dir="auto">
<li>
<p dir="auto">remove and re-clone from the remote repository</p>
</li>
<li>
<p dir="auto">manually add the symref (untested)</p>
</li>
</ol>