-
Notifications
You must be signed in to change notification settings - Fork 77
Indenting expression needs to be improved #35
Description
Given the playbook from http://docs.ansible.com/playbooks_intro.html:
---
- 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
gg=G
results in:
---
- 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
The indenting code seems to mix expressions that rely on different magic settings for Vim:
https://github.com/chase/vim-ansible-yaml/blob/master/indent/ansible.vim#L40-51
E.g. ':\s*[>|]?$'
should be '\v:\s*[>|]?$'
probably, and all patterns should explicitly state what mode to use, e.g. via \v
.
But that is not enough to fix this.
I've tried to address this, and the result would be:
---
- 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
This changes (decreases) the indentation of the handlers
list,
which is in line with the other lists.
Since I am new to Ansible I might be missing something, and probably there are different styles of indenting list entries?
However, keeping them in line to the start of the list made it easier to handle.
If I remember correctly it would not be possible to handle gg=G
then in all cases, because the previous lines would have been indented already.
I will provide a PR for this.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/11556485-indenting-expression-needs-to-be-improved?utm_campaign=plugin&utm_content=tracker%2F509109&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F509109&utm_medium=issues&utm_source=github).