0

How do I perform the following with Ansible playbook. I'm new to it. Thanks!

File example that contains the hostname and password

{ 
  "hosts":[
  {
      "node": "node1",
      "pass": "pass1"
  },
  {
      "node": "node2",
      "pass": "pass2"
  }
]}

I need to put file.txt on each server with their respected values.

Example, On node 1 the file.txt should contain the node name "node1" and password "pass1"

  • Is this file from some external source? Otherwise you would normally put such things in ansible host variables and use a template. – Michael Hampton Jul 07 '21 at 22:27
  • It's a local file on the ansible server. I don't want to use host variables since it contains passwords. I also need only place the file (file.txt) once on servers then run an external command then remove the file. – user772543 Jul 07 '21 at 22:30
  • You are familiar with Ansible Vault, yes? If it's a local file, is it not encrypted as Vault would do? – Michael Hampton Jul 07 '21 at 22:36

0 Answers0