From 26eec48954cd75f2c59ab4afbfb933f91b7aeaee Mon Sep 17 00:00:00 2001 From: Mathieu Trossevin Date: Thu, 18 Jun 2020 17:52:10 +0200 Subject: [PATCH] =?UTF-8?q?[Cleanup]=C2=A0amazon-ec2,=20apache,=20bind,=20?= =?UTF-8?q?evolinux-todo,=20evomaintenance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't compare with empty string Name all tasks Variables should have space before and after their name --- amazon-ec2/tasks/create-instance.yml | 30 ++++++++++++++-------------- apache/tasks/auth.yml | 2 +- apache/tasks/server_status.yml | 2 +- bind/tasks/main.yml | 2 +- evolinux-todo/tasks/cat.yml | 2 +- evomaintenance/tasks/main.yml | 6 ++++-- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/amazon-ec2/tasks/create-instance.yml b/amazon-ec2/tasks/create-instance.yml index 470cac72..c784b0b9 100644 --- a/amazon-ec2/tasks/create-instance.yml +++ b/amazon-ec2/tasks/create-instance.yml @@ -3,34 +3,34 @@ - name: Launch new instance(s) ec2: state: present - aws_access_key: "{{aws_access_key}}" - aws_secret_key: "{{aws_secret_key}}" - region: "{{aws_region}}" - image: "{{ec2_base_ami}}" - instance_type: "{{ec2_instance_type}}" - count: "{{ec2_instance_count}}" - assign_public_ip: "{{ec2_public_ip}}" - group: "{{ec2_security_group.name}}" - key_name: "{{ec2_keyname}}" + aws_access_key: "{{ aws_access_key }}" + aws_secret_key: "{{ aws_secret_key }}" + region: "{{ aws_region }}" + image: "{{ ec2_base_ami }}" + instance_type: "{{ ec2_instance_type }}" + count: "{{ ec2_instance_count }}" + assign_public_ip: "{{ ec2_public_ip }}" + group: "{{ ec2_security_group.name }}" + key_name: "{{ ec2_keyname }}" wait: yes register: ec2 - name: Add newly created instance(s) to inventory add_host: - hostname: "{{item.public_dns_name}}" + hostname: "{{ item.public_dns_name }}" groupname: launched-instances ansible_user: admin ansible_ssh_common_args: "-o StrictHostKeyChecking=no" - with_items: "{{ec2.instances}}" + with_items: "{{ ec2.instances }}" - debug: - msg: "Your newly created instance is reachable at: {{item.public_dns_name}}" - with_items: "{{ec2.instances}}" + msg: "Your newly created instance is reachable at: {{ item.public_dns_name }}" + with_items: "{{ ec2.instances }}" - name: Wait for SSH to come up on all instances (give up after 2m) wait_for: state: started - host: "{{item.public_dns_name}}" + host: "{{ item.public_dns_name }}" port: 22 timeout: 120 - with_items: "{{ec2.instances}}" + with_items: "{{ ec2.instances }}" diff --git a/apache/tasks/auth.yml b/apache/tasks/auth.yml index b785c704..d8488405 100644 --- a/apache/tasks/auth.yml +++ b/apache/tasks/auth.yml @@ -10,7 +10,7 @@ force: no tags: - apache - + - name: Load IP whitelist task include: ip_whitelist.yml diff --git a/apache/tasks/server_status.yml b/apache/tasks/server_status.yml index 1d6cd8df..79703d70 100644 --- a/apache/tasks/server_status.yml +++ b/apache/tasks/server_status.yml @@ -14,7 +14,7 @@ # The last character "\u000A" is a line feed (LF), it's better to keep it content: "{{ apache_serverstatus_suffix }}\u000A" force: yes - when: apache_serverstatus_suffix != "" + when: apache_serverstatus_suffix - name: generate random string for server-status suffix shell: "apg -a 1 -M N -n 1 > {{ apache_serverstatus_suffix_file }}" diff --git a/bind/tasks/main.yml b/bind/tasks/main.yml index 3ae02f24..625d3fe2 100644 --- a/bind/tasks/main.yml +++ b/bind/tasks/main.yml @@ -94,7 +94,7 @@ - debug: 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 replace: diff --git a/evolinux-todo/tasks/cat.yml b/evolinux-todo/tasks/cat.yml index 9cebeca5..30d13bce 100644 --- a/evolinux-todo/tasks/cat.yml +++ b/evolinux-todo/tasks/cat.yml @@ -10,4 +10,4 @@ - name: "Content of /etc/evolinux/todo.txt" debug: var: evolinux_todo.stdout_lines - when: evolinux_todo.stdout != "" + when: evolinux_todo.stdout diff --git a/evomaintenance/tasks/main.yml b/evomaintenance/tasks/main.yml index d56a124a..d58feaaa 100644 --- a/evomaintenance/tasks/main.yml +++ b/evomaintenance/tasks/main.yml @@ -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)') }}" -- assert: +- name: "Check that API variables are set" + assert: that: - evomaintenance_api_endpoint is not none - evomaintenance_api_key is not none