[Cleanup] amazon-ec2, apache, bind, evolinux-todo, evomaintenance

Don't compare with empty string

Name all tasks

Variables should have space before and after their name
This commit is contained in:
Mathieu Trossevin 2020-06-18 17:52:10 +02:00
parent 0825d88552
commit 26eec48954
Signed by: mtrossevin
GPG key ID: 81987323AE7F3E99
6 changed files with 23 additions and 21 deletions

View file

@ -3,34 +3,34 @@
- name: Launch new instance(s) - name: Launch new instance(s)
ec2: ec2:
state: present state: present
aws_access_key: "{{aws_access_key}}" aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{aws_secret_key}}" aws_secret_key: "{{ aws_secret_key }}"
region: "{{aws_region}}" region: "{{ aws_region }}"
image: "{{ec2_base_ami}}" image: "{{ ec2_base_ami }}"
instance_type: "{{ec2_instance_type}}" instance_type: "{{ ec2_instance_type }}"
count: "{{ec2_instance_count}}" count: "{{ ec2_instance_count }}"
assign_public_ip: "{{ec2_public_ip}}" assign_public_ip: "{{ ec2_public_ip }}"
group: "{{ec2_security_group.name}}" group: "{{ ec2_security_group.name }}"
key_name: "{{ec2_keyname}}" key_name: "{{ ec2_keyname }}"
wait: yes wait: yes
register: ec2 register: ec2
- name: Add newly created instance(s) to inventory - name: Add newly created instance(s) to inventory
add_host: add_host:
hostname: "{{item.public_dns_name}}" hostname: "{{ item.public_dns_name }}"
groupname: launched-instances groupname: launched-instances
ansible_user: admin ansible_user: admin
ansible_ssh_common_args: "-o StrictHostKeyChecking=no" ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
with_items: "{{ec2.instances}}" with_items: "{{ ec2.instances }}"
- debug: - debug:
msg: "Your newly created instance is reachable at: {{item.public_dns_name}}" msg: "Your newly created instance is reachable at: {{ item.public_dns_name }}"
with_items: "{{ec2.instances}}" with_items: "{{ ec2.instances }}"
- name: Wait for SSH to come up on all instances (give up after 2m) - name: Wait for SSH to come up on all instances (give up after 2m)
wait_for: wait_for:
state: started state: started
host: "{{item.public_dns_name}}" host: "{{ item.public_dns_name }}"
port: 22 port: 22
timeout: 120 timeout: 120
with_items: "{{ec2.instances}}" with_items: "{{ ec2.instances }}"

View file

@ -10,7 +10,7 @@
force: no force: no
tags: tags:
- apache - apache
- name: Load IP whitelist task - name: Load IP whitelist task
include: ip_whitelist.yml include: ip_whitelist.yml

View file

@ -14,7 +14,7 @@
# The last character "\u000A" is a line feed (LF), it's better to keep it # The last character "\u000A" is a line feed (LF), it's better to keep it
content: "{{ apache_serverstatus_suffix }}\u000A" content: "{{ apache_serverstatus_suffix }}\u000A"
force: yes force: yes
when: apache_serverstatus_suffix != "" when: apache_serverstatus_suffix
- name: generate random string for server-status suffix - name: generate random string for server-status suffix
shell: "apg -a 1 -M N -n 1 > {{ apache_serverstatus_suffix_file }}" shell: "apg -a 1 -M N -n 1 > {{ apache_serverstatus_suffix_file }}"

View file

@ -94,7 +94,7 @@
- debug: - debug:
var: chrootbind_run.stdout_lines var: chrootbind_run.stdout_lines
when: bind_chroot_set and chrootbind_run.stdout != "" when: bind_chroot_set and chrootbind_run.stdout
- name: Modify OPTIONS in /etc/default/bind9 for chroot - name: Modify OPTIONS in /etc/default/bind9 for chroot
replace: replace:

View file

@ -10,4 +10,4 @@
- name: "Content of /etc/evolinux/todo.txt" - name: "Content of /etc/evolinux/todo.txt"
debug: debug:
var: evolinux_todo.stdout_lines var: evolinux_todo.stdout_lines
when: evolinux_todo.stdout != "" when: evolinux_todo.stdout

View file

@ -1,9 +1,11 @@
--- ---
- set_fact: - name: "Choose if minifirewall will need to be restarted"
set_fact:
minifirewall_restart_handler_name: "{{ minifirewall_restart_if_needed | ternary('restart minifirewall', 'restart minifirewall (noop)') }}" minifirewall_restart_handler_name: "{{ minifirewall_restart_if_needed | ternary('restart minifirewall', 'restart minifirewall (noop)') }}"
- assert: - name: "Check that API variables are set"
assert:
that: that:
- evomaintenance_api_endpoint is not none - evomaintenance_api_endpoint is not none
- evomaintenance_api_key is not none - evomaintenance_api_key is not none