Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] apache.vhost.cleanup fails if apache is not yet installed #278

Closed
Yoda-BZH opened this issue Jun 9, 2020 · 2 comments · Fixed by #279
Closed

[BUG] apache.vhost.cleanup fails if apache is not yet installed #278

Yoda-BZH opened this issue Jun 9, 2020 · 2 comments · Fixed by #279

Comments

@Yoda-BZH
Copy link
Contributor

Yoda-BZH commented Jun 9, 2020

Your setup

Formula commit hash / release tag

Using apache and apache.vhost.cleanup on a new machine.

The test https://github.com/saltstack-formulas/apache-formula/blob/master/apache/vhosts/cleanup.sls#L24 fails as apache may not yet be installed.

Using commit id 2417a75

Versions reports (master & minion)

# salt -V
Salt Version:
           Salt: 3000.3
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.11
         Jinja2: 2.10
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.7.3 (default, Dec 20 2019, 18:57:59)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 17.1.2
          smmap: 2.0.5
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.1
 
System Versions:
           dist: debian 10.4 
         locale: UTF-8
        machine: x86_64
        release: 4.19.0-9-amd64
         system: Linux
        version: debian 10.4 

Same for master, syndic and minion

Pillar / config used

apache role (in pillarstack) :

states:
  list:
    - apache.debian_full
    - apache.mod_geoip
    - apache.mod_ssl
    - apache.mod_remoteip
    - apache.mod_mpm
    - apache.config
    - apache.modules
    - apache.manage_security
    - apache.vhosts.standard
    - apache.vhosts.cleanup

Bug details

Describe the bug

local:
    Data failed to compile:
----------
    Rendering SLS 'base:apache.vhosts.cleanup' failed: Problem running salt function in Jinja template: A valid directory was not specified.; line 24

---
[...]
{% for id, site in salt['pillar.get']('apache:register-site', {}) %}
{%   do valid_sites.append('{}{}'.format(site.name, apache.confext)) %}
{% endfor %}


{% for filename in salt['file.readdir']('/etc/apache2/sites-enabled/') %}    <======================
{%   if filename not in valid_sites %}

a2dissite {{ filename }}:
  cmd.run:
    - onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
[...]
---

Steps to reproduce the bug

Expected behaviour

cleanup should first test if the directory exists (or apache is installed), or fails silently if the directory is absent.

Attempts to fix the bug

None

Additional context

@Yoda-BZH Yoda-BZH added the bug label Jun 9, 2020
Yoda-BZH pushed a commit to Yoda-BZH/apache-formula that referenced this issue Jun 12, 2020
@myii
Copy link
Member

myii commented Jun 21, 2020

Thanks for the report, confirmed locally using Kitchen.

@myii myii closed this as completed in #279 Jun 21, 2020
myii pushed a commit that referenced this issue Jun 21, 2020
Co-authored-by: Tristan Charbonneau <tcharbonneau@oceanet-technology.com>

Fix #278
saltstack-formulas-travis pushed a commit that referenced this issue Jun 21, 2020
## [0.39.5](v0.39.4...v0.39.5) (2020-06-21)

### Bug Fixes

* **vhosts/cleanup:** check `sites-enabled` dir exists before listing it ([88373e3](88373e3)), closes [#278](#278)

### Continuous Integration

* **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([61b903e](61b903e))
* **kitchen:** use `saltimages` Docker Hub where available [skip ci] ([6895fb9](6895fb9))
* **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([16bb1b0](16bb1b0))
* **travis:** add notifications => zulip [skip ci] ([2417a75](2417a75))
* **workflows/commitlint:** add to repo [skip ci] ([2ce966d](2ce966d))
@saltstack-formulas-travis

🎉 This issue has been resolved in version 0.39.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants