Home > Back-end >  Ansible-config init option missing whe using ansible-config
Ansible-config init option missing whe using ansible-config

Time:09-21

I wanted to generate default config with init for ansible (version 2.10) but it looks like this option is not available for some reason. I don't know how I can autogenerate config file with everything commented as its told in the documentation:

ansible --version
ansible 2.10.8
  config file = /home/filip/DevOps/Ansible/ansible.cfg
  configured module search path = ['/home/filip/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
sudo ansible-config
usage: ansible-config [-h] [--version] [-v] {list,dump,view} ...
ansible-config: error: the following arguments are required: action
 
usage: ansible-config [-h] [--version] [-v] {list,dump,view} ...

View ansible configuration.

positional arguments:
  {list,dump,view}
    list            Print all config options
    dump            Dump configuration
    view            View configuration file

options:
  --version         show program's version number, config file location, configured module search path, module location, executable location and exit
  -h, --help        show this help message and exit
  -v, --verbose     verbose mode (-vvv for more, -vvvv to enable connection debugging)

CodePudding user response:

Ansible 2.10 does not support "init" as I know.
Probably you have installed old version from repository in Ubuntu.
Add ansible repository and update your Ansible:

sudo add-apt-repository --yes --update ppa:ansible/ansible

Now you should be able to install newest Ansible version:

sudo apt install ansible

Check again for your Ansible version:

ansible --version  

ansible [core 2.12.9]  

Now ansible-config should show init command available:

ansible-config -h  
...  
positional arguments:  
  {list,dump,view,init}  
    list                Print all config options  
    dump                Dump configuration  
    view                View configuration file  
    init                Create initial configuration   

To prepare init config for example:

ansible-config init -f ini > config.ini

The -f flag determines format of your config file (-f {ini,env,vars}).

  • Related