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] allow and deny items parsed on single line #50

Closed
Mandorath opened this issue May 12, 2020 · 8 comments · Fixed by #52
Closed

[BUG] allow and deny items parsed on single line #50

Mandorath opened this issue May 12, 2020 · 8 comments · Fixed by #52

Comments

@Mandorath
Copy link

Mandorath commented May 12, 2020

Your setup

Formula commit hash / release tag

The formula used is v0.11.1, I checked the code in the master branch and it has the same problem.

Versions reports (master & minion)

Salt Version:
Salt: 2019.2.4

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.33.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Aug 7 2019, 17:28:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.2
ZMQ: 4.1.4

System Versions:
dist: centos 7.7.1908 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.18.1.el7.x86_64
system: Linux
version: CentOS Linux 7.7.1908 Core

Pillar / config used

Below an example of the pillar file used. Note the allow key.

dhcpd:
    domain_name: example.org
    authoritative: false
    omapi_port: port
    omapi_key: key
    next-server: ip-address
    ddns_update_style: none
    keys:                    # Replace values below with created key
      key:
          algorithm: algorithm
          secret: key
    allow:
      - booting
      - bootp
    domain_name_servers:
        - ns1.example.org       # replace and add the local dns server if exists
    default_lease_time: 43200
    max_lease_time: 86400
    log_facility: local7

Bug details

Describe the bug

When running the formula and adding items 'allow' items in the pillar file they are pasted after each other and after the last item declared before it. This is caused to due to the for loop stripping the new lines. The first option when not specified is dhcpd.use_host_decl_names, which when not specified pastes the allow items behind a commented item.

Output:
#use-host-decl-names off;allow booting;allow bootp;

Steps to reproduce the bug

Do not specify the key dhcpd.use_host_decl_names and add several allow items like shown in the pillar example.

Expected behaviour

Output everything with newlines properly like show below.

#use-host-decl-names off;

allow booting;
allow bootp;

Attempts to fix the bug

Below the dhcp.allow with the allow in its own line

    {%- if dhcpd.allow %}
      {% if dhcpd.allow is iterable and dhcpd.allow  is not string %}  
        {%- for item in dhcpd.allow  %}  
allow {{ item }};  
       {%- endfor %}  
      {%- else %}
allow {{ dhcpd.allow }};  
      {%- endif %}  
    {%- endif %}  

Using the code above will result in the mentioned expected outcome

Additional context

@Mandorath Mandorath added the bug label May 12, 2020
@Mandorath
Copy link
Author

Not sure why markdown code block is ignoring new lines, tried several methods...

@myii
Copy link
Member

myii commented May 12, 2020

@Mandorath Have a look at the edit I made. You need to gate the code block with three backticks and you can add an optional code language for colour highlighting. So that was:

```jinja
    {%- if dhcpd.allow %}
      {% if dhcpd.allow is iterable and dhcpd.allow  is not string %}  
        {%- for item in dhcpd.allow  %}  
    allow {{ item }};  
       {%- endfor %}  
      {%- else %}allow {{ dhcpd.allow }};  
      {%- endif %}  
    {%- endif %} 
```

@Mandorath Mandorath changed the title [BUG] [BUG] allow and deny items parsed on single line May 12, 2020
@Mandorath
Copy link
Author

Mandorath commented May 12, 2020

@myii Thanks! I'm still reading myself up on all of this :).

@geertwitter
Copy link

Hello, any progress on this item? It would be nice to have an update on this formula with the bug fixed.

myii added a commit to myii/dhcpd-formula that referenced this issue Sep 23, 2020
myii added a commit to myii/dhcpd-formula that referenced this issue Sep 23, 2020
@myii myii mentioned this issue Sep 23, 2020
19 tasks
@myii
Copy link
Member

myii commented Sep 23, 2020

@Mandorath @geertwitter Fix proposed in #52. Feel free to test it out and comment there.

Tricked by @daks (in Slack) into working on this!!

@geertwitter
Copy link

Thanks for the fast response!

@myii myii closed this as completed in #52 Sep 24, 2020
@myii
Copy link
Member

myii commented Sep 24, 2020

@Mandorath @geertwitter Fix has been merged, let us know if there are any problems, either here or in #52.

saltstack-formulas-travis pushed a commit that referenced this issue Sep 24, 2020
## [0.11.2](v0.11.1...v0.11.2) (2020-09-24)

### Bug Fixes

* **dhcpd.conf:** fix bug 50 ([e015cda](e015cda)), closes [#50](#50)

### Continuous Integration

* **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([e3d3bb3](e3d3bb3))
* **kitchen:** use `saltimages` Docker Hub where available [skip ci] ([6e5d4fe](6e5d4fe))
* **kitchen+travis:** add new platforms [skip ci] ([2e3f86e](2e3f86e))
* **kitchen+travis:** adjust matrix to add `3000.2` & remove `2018.3` [skip ci] ([1eac3c9](1eac3c9))
* **kitchen+travis:** adjust matrix to add `3000.3` [skip ci] ([4fa9cb5](4fa9cb5))
* **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([aa2f881](aa2f881))
* **travis:** add notifications => zulip [skip ci] ([1726c5a](1726c5a))
* **workflows/commitlint:** add to repo [skip ci] ([9572bd8](9572bd8))
@saltstack-formulas-travis

🎉 This issue has been resolved in version 0.11.2 🎉

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.

4 participants