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

Indenting with Ansible YAML #1

Open
blueyed opened this issue Apr 20, 2015 · 0 comments
Open

Indenting with Ansible YAML #1

blueyed opened this issue Apr 20, 2015 · 0 comments

Comments

@blueyed
Copy link

blueyed commented Apr 20, 2015

I am looking into indenting for Ansible's YAML, e.g.:


---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: root
  tasks:
  - name: ensure apache is at the latest version
    yum: pkg=httpd state=latest
  - name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf
    notify:
    - restart apache
  - name: ensure apache is running (and enable it at boot)
    service: name=httpd state=started enabled=yes
  handlers:
    - name: restart apache
      service: name=httpd state=restarted

(from http://docs.ansible.com/playbooks_intro.html)

With your plugin this gets indented as (using gg=G):


---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
    remote_user: root
    tasks:
      - name: ensure apache is at the latest version
        yum: pkg=httpd state=latest
        - name: write the apache config file
          template: src=/srv/httpd.j2 dest=/etc/httpd.conf
          notify:
            - restart apache
            - name: ensure apache is running (and enable it at boot)
              service: name=httpd state=started enabled=yes
              handlers:
                - name: restart apache
                  service: name=httpd state=restarted

According to http://www.yamllint.com/ it is valid.

I have tried to improve another plugin, specifically targeted at Ansible, before (chase/vim-ansible-yaml#36), but it looks like your approach might be better (using the context).

Apart from that you have tests.. :)

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

No branches or pull requests

1 participant