Change SSH Port and User

22 views
Skip to first unread message

Silvio Siefke

unread,
Oct 16, 2022, 5:41:47 PM10/16/22
to Ansible Project
Hello,

I try to run a deployment Playbook with some roles like bootstraping,
user and ssh server.
The configuration for hosts I put in host_vars folder.

The host file:

ansible_user: "vagrant"
ansible_pass: "vagrant"
ansible_ssh_pass: "vagrant"
ansible_become_pass: "vagrant"
ansible_port: "22"


The playbook:

- name: Deploy the server
  hosts: vb_deb
  become: yes
  gather_facts: yes
  strategy: free
  tasks:
    - name: Let us bootstraping the server
      ansible.builtin.include_role:
        name: core_bootstrap
    - name: Let us install core packages
      ansible.builtin.include_role:
        name: core_packages
    - name: Let us create the user on server
      ansible.builtin.include_role:
        name: core_users
    - name: Let us install and configure the OpenSSH Server
      ansible.builtin.include_role:
        name: core_openssh

So now I had the problem the ssh user and the ssh port change to my
username and 12000 for SSH.

How can I delete the variables (ansible_pass, ansible_ssh_pass,
ansible_become_pass, ansible_port) in
host_vars file with ansible so that the default settings be used and I
can run the next role?


Thank you for help.

Silvio

Brian Coca

unread,
Oct 17, 2022, 1:41:19 PM10/17/22
to ansible...@googlegroups.com
I would put the variable sin the bootstrapping play instead, once the
play runs out of scope (next play) the variables will be gone.
--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages