# Create remotly server and still on it to other installations.

**URL:** <https://forum.ansible.com/t/create-remotly-server-and-still-on-it-to-other-installations/22491>\
**Category:** Ansible Project\
**Created:** [September 5, 2016, 5:48pm UTC](https://forum.ansible.com/t/create-remotly-server-and-still-on-it-to-other-installations/22491 "2016-09-05T17:48:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![weslley.azevedo](https://avatars.discourse-cdn.com/v4/letter/w/a8b319/32.png) [@weslley.azevedo](https://forum.ansible.com/u/weslley.azevedo)\
**Post date:** [September 5, 2016, 5:48pm UTC](https://forum.ansible.com/t/create-remotly-server-and-still-on-it-to-other-installations/22491/1 "2016-09-05T17:48:53Z")

</div>

Hello,

I have been working to create a server on Linode via ansible, and i can do it by a playbook but when I try to use it with the best practices(Roles) I am not getting well.

Can anyone help me ?

Basically it creates the linode server and when it goes to the next step which will set hostname it doesnt connect to the server. It fails to connect automatically using the ssh public key.

Using roles :

--------------------------------------------- main playbook-----------------------------------------------

- hosts: localhost  
connection: local  
gather\_facts: false

roles:

# - users

# - updates

# - monitoring

- linode1

- hosts: linode ------- I do get it data from a running playbook  
become: true

roles:

- linodeteste  
------------------------------------------------------linode1.yml---------------------------

- include\_vars: config.yml

- name: Fail if server\_hostname is not defined  
fail: msg=“server\_hostname needs to be defined via commandline, e.g. --extra-vars server\_hostname=flower”  
when: server\_hostname is not defined

- name: Create linode server via Linode API  
linode:  
name: “{{ server\_hostname }}”  
plan: “{{ linode\_plan }}”  
datacenter: “{{ linode\_datacenter }}”  
distribution: “{{ linode\_distribution }}”  
ssh\_pub\_key: “{{ root\_ssh\_pub\_key }}”  
swap: “{{ linode\_swap }}”  
wait: yes  
wait\_timeout: 600  
state: present  
register: linode

- name: Show me the registered linode  
debug: var=linode

- name: Add new host to in-memory inventory  
add\_host:  
hostname: “{{ linode.instance.ipv4 }}”  
groupname: “linode”

- name: Wait for Linode to listen on port 22  
wait\_for:  
state: started  
host: “{{ linode.instance.ipv4 }}”  
port: 22  
------------------------------linodeteste.yml------------------------

- include\_vars: roles/linode/vars/config.yml

vars:  
server\_fqdn: “{{ server\_hostname }}.{{ server\_domain }}”

- name: set hostname  
hostname: name=“{{ server\_hostname }}”

- name: set FQDN  
lineinfile:  
dest=/etc/hosts  
regexp=‘{{ item }}$’  
line=“{{ item }} {{ server\_fqdn }} {{ server\_hostname }}”  
state=present  
with\_items: groups[‘linode’]  
become: true

- name: ssh key only  
copy: src=files/ssh/sshd\_config dest=/etc/ssh/sshd\_config  
notify: restart ssh

- name: Adição de usuarios  
user: name={{ item.name }} shell=/bin/bash state=present groups={{ item.groups }}  
with\_items:

- { name: ‘weslley’, groups: ‘sudo’ }  
become: true

- name: “Autorizando acesso dos usuarios com chave de SSH.”  
authorized\_key: user={{item.name}} key=“{{ lookup(‘file’, ‘id\_rsa.{{item.name}}.pub’) }}” exclusive=yes  
with\_items:

- { name: ‘weslley’ }  
become: true

handlers:

- name: restart ssh  
service: name=ssh state=restarted

My error :

ECDSA key fingerprint is 78:95:7e:35:a4  
Are you sure you want to continue connecting (yes/no)? yes  
fatal: [66.228.50.17]: UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh.”, “unreachable”: true}  
[WARNING]: Could not create retry file ‘pontoweb.retry’. [Errno 2] No such file or directory: ‘’
