Skip to content

Commit

Permalink
Merge pull request #1 from AutomationWithAnsible/feature/remove-tab
Browse files Browse the repository at this point in the history
Remove tab char \t
  • Loading branch information
ahelal committed Jan 8, 2016
2 parents fc13407 + dcfe1e2 commit c3f46f0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ install:

script:
# 1st: check syntax
- ansible-playbook -i tests/inv.ini tests/test_travis.yml --syntax-check
- ansible-playbook -i tests/play.ini tests/test_default.yml --syntax-check

# 2nd: Make sure we run the entire playbook
- ansible-playbook -i tests/inv.ini tests/test_travis.yml --sudo
- ansible-playbook -i tests/play.ini tests/test_default.yml --sudo

# 3rd: Make sure our playbook is idempotent
- >
ansible-playbook -i tests/option1.ini tests/test_travis.yml --sudo
ansible-playbook -i tests/play.ini tests/test_default.yml --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# 4th: options test
- ./tests/test_logs.sh
|| (echo 'Idempotence test: fail' && exit 1)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ hostname_sub_replace : false
hostname_hosts_file :
- regexp : "^127.0.0.1"
line : "127.0.0.1{{'\t'}}localhost"
line : "127.0.0.1 localhost"
- regexp : "^127.0.1.1"
line : "127.0.1.1{{ lookup('template', '../templates/hosts_file.j2') }}"
```

# TODO
use server sepc for test
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ hostname_sub_replace : false

hostname_hosts_file :
- regexp : "^127.0.0.1"
line : "127.0.0.1{{'\t'}}localhost"
line : "127.0.0.1 localhost"

- regexp : "^127.0.1.1"
line : "127.0.1.1{{ lookup('template', '../templates/hosts_file.j2') }}"
2 changes: 1 addition & 1 deletion templates/hosts_file.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{'\t'}}{{hostname_fqdn}}{% if hostname_fqdn != hostname_short %}{{'\t'}}{{hostname_short}}{% endif %}{% if inventory_hostname.split(".")[0] != hostname_short %}{{'\t'}}{{ inventory_hostname.split(".")[0] }}{% endif %}
{{hostname_fqdn}}{% if hostname_fqdn != hostname_short %} {{hostname_short}}{% endif %}{% if inventory_hostname.split(".")[0] != hostname_short %} {{ inventory_hostname.split(".")[0] }}{% endif %}
5 changes: 3 additions & 2 deletions tests/test_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- hosts: test
sudo: yes
vars:
correct_short_hostname: "default.berlin.de.example.com"
correct_short_hostname: "play.berlin.de.example.com"
#remote_user: root
roles:
- ansible-hostname
Expand All @@ -11,7 +11,8 @@
command: hostname
register: my_hostname
changed_when: False

- debug: var=my_hostname
- debug: var=correct_short_hostname
- name: Assert hostname command
assert:
that:
Expand Down

0 comments on commit c3f46f0

Please sign in to comment.