# Ansible-pull systemd unit fails

**URL:** <https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298>\
**Category:** Get Help\
**Tags:** systemd\
**Created:** [December 23, 2024, 3:02pm UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298 "2024-12-23T15:02:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hipska/32/5521_2.png) [@Hipska](https://forum.ansible.com/u/Hipska)\
**Post date:** [December 23, 2024, 3:02pm UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/1 "2024-12-23T15:02:49Z")

</div>

I now have the very weird problem ansible-pull works perfectly fine as user ansible, but when doing the same from a systemd service fails without any useful logs apart from this:

```auto
systemd[1]: ansible-pull.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
systemd[1]: ansible-pull.service: Failed with result 'exit-code'.

```

The unit file looks like this:

```auto
[Unit]
Description=Manage server configuration with ansible-pull
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ansible-pull -U https://example.com/ansible.git --clean --diff initiate.yml
User=ansible

[Install]
WantedBy=multi-user.target

```

Anyone have a clue what might be wrong, or how I could get more detailed logs or error messages?

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [December 25, 2024, 3:22am UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/2 "2024-12-25T03:22:19Z")

</div>

Wouldn’t you need to specify where to pull it too?

```
  $ ansible-pull --help | grep DEST
                [--purge] [-o] [-s SLEEP] [-f] [-d DEST] [-U URL] [--full]
  -d, --directory DEST path to the directory to which Ansible will checkout

```

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hipska/32/5521_2.png) [@Hipska](https://forum.ansible.com/u/Hipska)\
**Post date:** [January 6, 2025, 8:05am UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/3 "2025-01-06T08:05:12Z")

</div>

If not specified, it will pull into `~/.ansible/pull/HOSTNAME`, but even when the command is simply `ansible-pull --version` it fails similarly.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 6, 2025, 12:30pm UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/4 "2025-01-06T12:30:58Z")

</div>

There are more details in the system journal. For example, running `journalctl -b -u ansible-pull --no-hostname -o short --no-pager` after having attempted to start your service from your initial post on my system produces:

```auto
$ sudo journalctl -b -u ansible-pull --no-hostname -o short --no-pager
Jan 06 07:10:50 systemd[1]: Starting ansible-pull.service - Manage server configuration with ansible-pull...
Jan 06 07:10:51 python3[37407]: ansible-git Invoked with name=https://example.com/ansible.git dest=/home/ansible/.ansible/pull/foxtrot depth=1 force=True repo=https://example.com/ansible.git version=HEAD remote=origin clone=True update=True verify_commit=False gpg_whitelist=[] accept_hostkey=False accept_newhostkey=False bare=False recursive=True single_branch=False track_submodules=False refspec=None reference=None key_file=None ssh_opts=None executable=None umask=None archive=None archive_prefix=None separate_git_dir=None
Jan 06 07:10:53 ansible-pull[37389]: [WARNING]: Could not match supplied host pattern, ignoring: foxtrot
Jan 06 07:10:53 ansible-pull[37389]: localhost | FAILED! => {
Jan 06 07:10:53 ansible-pull[37389]: "changed": false,
Jan 06 07:10:53 ansible-pull[37389]: "cmd": "/usr/bin/git ls-remote https://example.com/ansible.git -h refs/heads/HEAD",
Jan 06 07:10:53 ansible-pull[37389]: "msg": "fatal: repository 'https://example.com/ansible.git/' not found",
Jan 06 07:10:53 ansible-pull[37389]: "rc": 128,
Jan 06 07:10:53 ansible-pull[37389]: "stderr": "fatal: repository 'https://example.com/ansible.git/' not found\n",
Jan 06 07:10:53 ansible-pull[37389]: "stderr_lines": [
Jan 06 07:10:53 ansible-pull[37389]: "fatal: repository 'https://example.com/ansible.git/' not found"
Jan 06 07:10:53 ansible-pull[37389]: ],
Jan 06 07:10:53 ansible-pull[37389]: "stdout": "",
Jan 06 07:10:53 ansible-pull[37389]: "stdout_lines": []
Jan 06 07:10:53 ansible-pull[37389]: }
Jan 06 07:10:53 ansible-pull[37389]: Starting Ansible Pull at 2025-01-06 07:10:51
Jan 06 07:10:53 ansible-pull[37389]: /usr/bin/ansible-pull -U https://example.com/ansible.git --clean --diff initiate.yml
Jan 06 07:10:53 systemd[1]: ansible-pull.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jan 06 07:10:53 systemd[1]: ansible-pull.service: Failed with result 'exit-code'.
Jan 06 07:10:53 systemd[1]: Failed to start ansible-pull.service - Manage server configuration with ansible-pull.
Jan 06 07:10:53 systemd[1]: ansible-pull.service: Consumed 873ms CPU time, 139.3M memory peak.

```

Obviously mine failed because I didn’t point at a valid https repo, but the point is there’s more information in the system journal than is reported by `systemctl status ansible-pull.service`.

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hipska/32/5521_2.png) [@Hipska](https://forum.ansible.com/u/Hipska)\
**Post date:** [January 24, 2025, 3:30pm UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/5 "2025-01-24T15:30:58Z")

</div>

Thanks, I have no idea what was changed, but just tried again and now it works…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 23, 2025, 3:31pm UTC](https://forum.ansible.com/t/ansible-pull-systemd-unit-fails/39298/6 "2025-02-23T15:31:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
