diff --git a/blogs.yaml b/blogs.yaml index 2c7fbe4..08367f2 100644 --- a/blogs.yaml +++ b/blogs.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: blogs - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: blogs - hosts: blogs roles: diff --git a/ldap.yaml b/ldap.yaml index 3886082..a5f4df0 100644 --- a/ldap.yaml +++ b/ldap.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: ldap - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: ldap - hosts: ldap roles: diff --git a/lists.yaml b/lists.yaml index de422d7..1f37536 100644 --- a/lists.yaml +++ b/lists.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: lists - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: lists - hosts: lists roles: diff --git a/logger.yaml b/logger.yaml index 0bddab5..1c7471b 100644 --- a/logger.yaml +++ b/logger.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: logger - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: logger - hosts: all diff --git a/mail.yaml b/mail.yaml index ee7655b..bcc058b 100644 --- a/mail.yaml +++ b/mail.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: mail - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: mail - hosts: mail roles: diff --git a/projects.yaml b/projects.yaml index 29e8d04..0aa7456 100644 --- a/projects.yaml +++ b/projects.yaml @@ -5,7 +5,7 @@ vm_name: projects # distro: sid - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: projects - hosts: projects roles: diff --git a/requirements.txt b/requirements.txt index 285aff4..f4a1a72 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ansible==2.2.1.0 +ansible==2.2.0.0 appdirs==1.4.3 asn1crypto==0.22.0 cffi==1.10.0 diff --git a/roles/ssh_server/tasks/main.yaml b/roles/ssh_server/tasks/main.yaml index a9454f9..5517e5c 100644 --- a/roles/ssh_server/tasks/main.yaml +++ b/roles/ssh_server/tasks/main.yaml @@ -26,7 +26,7 @@ - name: generate host request set_fact: - cert_request: + ca_request: type: 'sign_request' request: keyType: 'ssh_host' @@ -34,16 +34,13 @@ keyData: "{{ vm_public_key['content'] | b64decode | replace('\n', '')}}" - debug: - var: cert_request | to_json + var: ca_request | to_json verbosity: 2 - name: start sign request - raw: "{{ cert_request | to_json }}" - delegate_to: ca_request - delegate_facts: True - connection: ssh - register: request_result - failed_when: "( request_result.stdout | from_json ).failed" + include: ca-dialog.yaml + vars: + ansible_connection: ssh - debug: var: request_result @@ -58,31 +55,29 @@ - name: generate get request set_fact: - get_request: + ca_request: type: 'get_certificate' requestID: '{{ request_output.requestID }}' - debug: - var: get_request + var: ca_request verbosity: 2 - debug: msg: "Please manualy confirm sign request with id {{ request_output.requestID }}" - name: wait for cert - raw: "{{ get_request | to_json }}" - delegate_to: ca_request - delegate_facts: True - connection: ssh - register: cert_result - failed_when: "(cert_result.stdout | from_json).failed" + include: ca-dialog.yaml + vars: + ansible_connection: ssh + request: get_request - debug: - var: cert_result + var: request_result verbosity: 2 - set_fact: - cert_key: "{{ cert_result.stdout | string | from_json }}" + cert_key: "{{ request_result.stdout | string | from_json }}" - name: Write certificate to container copy: @@ -118,7 +113,7 @@ - meta: flush_handlers -- name: "waiting for ssh on {{ inventory_hostname }} vm to start" +- name: "waiting for ssh on {{ ansible_docker_extra_args | default(inventory_hostname) }} to start" wait_for: host: "{{ hostvars[inventory_hostname]['ansible_host'] }}" port: 22 diff --git a/tasks/ca-dialog.yaml b/tasks/ca-dialog.yaml new file mode 100644 index 0000000..4b2c5dc --- /dev/null +++ b/tasks/ca-dialog.yaml @@ -0,0 +1,5 @@ +- raw: "{{ ca_request | to_json }}" + delegate_to: ca_request + delegate_facts: True + register: request_result + failed_when: "( request_result.stdout | from_json ).failed" diff --git a/team_server.yaml b/team_server.yaml index aec05f8..b4e9e38 100644 --- a/team_server.yaml +++ b/team_server.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: team - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: team - hosts: team roles: diff --git a/users.yaml b/users.yaml index 7bb49be..5fe2a9e 100644 --- a/users.yaml +++ b/users.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: users - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: users - hosts: users roles: diff --git a/webmail.yaml b/webmail.yaml index 9e814d1..ee8b554 100644 --- a/webmail.yaml +++ b/webmail.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: webmail - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: webmail - hosts: webmail roles: diff --git a/wiki.yaml b/wiki.yaml index 6d315ba..1ecc34f 100644 --- a/wiki.yaml +++ b/wiki.yaml @@ -4,7 +4,7 @@ - role: lxc_guest vm_name: wiki - role: ssh_server - connection: lxc_ssh + ansible_connection: lxc_ssh ansible_docker_extra_args: wiki - hosts: wiki roles: