From 46eb78d33b58cd31114fc65150f406abde4641d1 Mon Sep 17 00:00:00 2001 From: "Jon \"The Nice Guy\" Spriggs" Date: Tue, 5 Dec 2023 12:56:09 +0000 Subject: [PATCH] Improve simplicity of ansible_local inventory * Remove separate inventory file and config file * Define nodes in Vagrantfile --- .../docs/provisioning/ansible_local.mdx | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/website/content/docs/provisioning/ansible_local.mdx b/website/content/docs/provisioning/ansible_local.mdx index 790b94e156d..4b586c752ea 100644 --- a/website/content/docs/provisioning/ansible_local.mdx +++ b/website/content/docs/provisioning/ansible_local.mdx @@ -212,30 +212,26 @@ Vagrant.configure("2") do |config| ansible.verbose = true ansible.install = true ansible.limit = "all" # or only "nodes" group, etc. - ansible.inventory_path = "inventory" + ansible.groups = { + "nodes" => ["node1", "node2"], + "localhost" => ["controller"] + } + ansible.host_vars = { + "node1" => { + "ansible_user" => "vagrant", + "ansible_host" => "172.17.177.21", + "ansible_ssh_private_key_file" => "/vagrant/.vagrant/machines/node1/virtualbox/private_key", + "ansible_host_key_checking" => false + }, + "node2" => { + "ansible_user" => "vagrant", + "ansible_host" => "172.17.177.22", + "ansible_ssh_private_key_file" => "/vagrant/.vagrant/machines/node2/virtualbox/private_key", + "ansible_host_key_checking" => false + }, + } end end end ``` - -You need to create a static `inventory` file that corresponds to your `Vagrantfile` machine definitions: - -``` -controller ansible_connection=local -node1 ansible_host=172.17.177.21 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node1/virtualbox/private_key -node2 ansible_host=172.17.177.22 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node2/virtualbox/private_key - -[nodes] -node[1:2] -``` - -And finally, you also have to create an [`ansible.cfg` file](https://docs.ansible.com/intro_configuration.html#openssh-specific-settings) to fully disable SSH host key checking. More SSH configurations can be added to the `ssh_args` parameter (e.g. agent forwarding, etc.) - -``` -[defaults] -host_key_checking = no - -[ssh_connection] -ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -```