saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

[BUG] git state module says could not resolve dns and fails #61810

Open DevOps-Clinic opened 2 years ago

DevOps-Clinic commented 2 years ago

Description I have a basic state which calls the Nginx and PHP-FPM formulas to get them installed, then sets some firewall rules, then uses git.latest to pull in a git url. If I go to the command line and issue a "git clone url" it works fine, but running as salt state it fails. I've tried both different git hosted sites (GitLab and GitHub) and neither seem to matter. I've tested on Linode vm's, Parallells vm's, Virtualbox vm's, and even physical servers. Tested both in my work environment and my home lab. I've also tried disabling firewalld to see if that was blocking it, and that didn't help. Network firewalls are pretty basic, allow all outbound but limited inbound NATs.

If I run the state twice, the second time it always succeeds, but it always fails on the first attempt. I know in the past I've used syntax like this to pull in git repos, but never came across this error. DNS is correctly setup in all the different environments I've tested this. Any ideas?

Setup Here is the roles.webserver.init.sls

include:
  - core.packages
  - core.users.user_www_data
  - php.fpm
  - core.services.firewalld
  - nginx

webserver-firewalld-rules:
  firewalld.present:
    - name: public
    - services:
      - http
      - https
    - prune_services: False

webserver-firewalld-service:
  service.running:
    - name: firewalld
    - reload: True
    - watch:
      - firewalld: public

webserver-www-content-download:
  git.latest:
    - name: https://gitlab.com/DevOpsClinic/sample-php-website.git
#    - name: https://github.com/DevOps-Clinic/sample-php-website.git
    - target: /var/www/html
    - branch: main

Here is the core.packages.init.sls:

core-packages-install:
  pkg.latest:
    - pkgs:
      - bash-completion
      - bzip2
      - curl
      - epel-release
      - git
      - jq
      - tmux
      - unzip
      - vim-minimal
      - vim-common
      - vim-enhanced
      - wget
      - zsh

core-packages-pygit:
  pkg.latest:
    - pkgs:
      - python3-GitPython
    - require:
      - core-packages-install

From /var/log/salt/minion

Mar 19 12:59:37 minion1 salt-minion[946]: [ERROR   ] Command 'git' failed with return code: 128
Mar 19 12:59:37 minion1 salt-minion[946]: [ERROR   ] stderr: fatal: unable to access 'https://gitlab.com/DevOpsClinic/sample-php-website.git/': Could not resolve host: gitlab.com
Mar 19 12:59:37 minion1 salt-minion[946]: [ERROR   ] retcode: 128
Mar 19 12:59:37 minion1 salt-minion[946]: [ERROR   ] Failed to check remote refs: fatal: unable to access 'https://gitlab.com/DevOpsClinic/sample-php-website.git/': Could not resolve host: gitlab.com

salt-output.log

Please be as specific as possible and give set-up details.

Steps to Reproduce the behavior salt "minion1" state.apply

Expected behavior I expect it to pull down the remote Git repo

Screenshots See logs

Versions Report Both master and minion are running same OS and same Salt version:

[root@minion1 ~]# salt-call test.versions_report
local:
    Salt Version:
              Salt: 3004

    Dependency Versions:
              cffi: Not Installed
          cherrypy: Not Installed
          dateutil: 2.6.1
         docker-py: Not Installed
             gitdb: 4.0.1
         gitpython: 3.0.9
            Jinja2: 2.10.1
           libgit2: Not Installed
          M2Crypto: 0.35.2
              Mako: Not Installed
           msgpack: 0.6.2
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         pycparser: Not Installed
          pycrypto: Not Installed
      pycryptodome: Not Installed
            pygit2: Not Installed
            Python: 3.6.8 (default, Nov  9 2021, 14:44:26)
      python-gnupg: Not Installed
            PyYAML: 3.12
             PyZMQ: 19.0.0
             smmap: 3.0.1
           timelib: Not Installed
           Tornado: 4.5.3
               ZMQ: 4.3.4

    System Versions:
              dist: rocky 8.5 Green Obsidian
            locale: UTF-8
           machine: x86_64
           release: 4.18.0-348.20.1.el8_5.x86_64
            system: Linux
           version: Rocky Linux 8.5 Green Obsidian
welcome[bot] commented 2 years ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

DevOps-Clinic commented 2 years ago

Just wanted to follow up. If there's another test I can run let me know. Thanks

frogunder commented 2 years ago

I am not able to replicate this, maybe someone from @saltstack/team-core can take a look when they have time? Thanks.