saltstack / saltstack/salt

[BUG] git.latest fails with permission error on macOS when using identity file and non-standard user

Open
#57,233 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug MacOS pending-discussion
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
When using git.latest I get a permission error if using the user parameter combined with the identity parameter.

Edit: Looks like this only happens when I am trying to run this state against a minion that is running on the same machine as the master. This works fine if used on a minion running on another machine...

----:
----------
          ID: states.git.clone_---- - Clone ---- repo or pull latest
    Function: git.latest
        Name: git@github.com:----
      Result: False
     Comment: Failed to check remote refs: Unable to authenticate using identity file:

              git@github.com: Permission denied (publickey).
              fatal: Could not read from remote repository.

              Please make sure you have the correct access rights
              and the repository exists.
     Started: 17:22:17.809552
    Duration: 1664.535 ms
     Changes:

Setup
sls file that fails:

{{ sls }} - Clone ---- repo or pull latest:
  git.latest:
    - name: git@github.com:----
    - target: {{ pillar['minion_home'] }}/git/----
    - user: {{ pillar['minion_user'] }}
    - branch: master
    - identity: salt://data/ssh/----_deploy_key
    - force_checkout: True
    - force_fetch: True
    - force_reset: remote-changes

sls file that works (but clones/updates repo as root):

{{ sls }} - Clone ---- repo or pull latest:
  git.latest:
    - name: git@github.com:----
    - target: {{ pillar['minion_home'] }}/git/----
    - branch: master
    - identity: salt://data/ssh/----_deploy_key
    - force_checkout: True
    - force_fetch: True
    - force_reset: remote-changes
  • minion_user is just a different user than root in this case
  • minion_home is the above user's home directory

Expected behavior
The repo should be cloned/updated to latest correctly by the user specified using the user parameter.

Versions Report

salt --versions-report
Salt Version:
           Salt: 3000.1

Dependency Versions:
           cffi: 1.12.2
       cherrypy: unknown
       dateutil: 2.8.0
      docker-py: Not Installed
          gitdb: 2.0.6
      gitpython: 2.1.15
         Jinja2: 2.10.1
        libgit2: 1.0.0
       M2Crypto: 0.35.2
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 3.8.1
   pycryptodome: Not Installed
         pygit2: 1.2.0
         Python: 3.7.7 (default, Mar 10 2020, 15:43:27)
   python-gnupg: 0.4.4
         PyYAML: 5.1.2
          PyZMQ: 18.0.1
          smmap: 3.0.2
        timelib: 0.2.4
        Tornado: 4.5.3
            ZMQ: 4.3.1

System Versions:
           dist:
         locale: UTF-8
        machine: x86_64
        release: 17.7.0
         system: Darwin
        version: 10.13.6 x86_64

Additional context
This seems like it might be related to: #42550

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the git.latest execution path and compare how the user and identity parameters are handled for a local minion versus a remote minion. Reproduce the failure on macOS using the provided SLS configuration; done means the repository is cloned or updated successfully as the specified non-root user.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, macos, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.