Answer the question
In order to leave comments, you need to log in
How to automate the value generation process for Ansible?
Hello!
Faced the issue of fully automating the server deployment process using ansible.
On each server I use different variable values: ssh port number, grub password, usernames, their passwords, and a number of other various data.
Tell me, is there any ready-made solution for generating such values (a number, an arbitrary set of characters), the use of which will generate the necessary values of variables for var ansible, and which I will later use in templates and other modules.
Thank you!
Answer the question
In order to leave comments, you need to log in
To generate a password (or any other parameter) use lookup, here is an example of user generation with automatic password generation
- name: create users
user:
name: "{{ item }}"
createhome: yes
state: present
password: "{{ lookup('password', '/tmp/' + ansible_host + '_' + item + '_password.txt encrypt=md5_crypt chars=ascii_letters,digits length=1
update_password: on_create
with_items:
- "{{ users }}"
register: newuser
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question