I have an ansible.cfg file. Ansible isn't behaving as expected for me, but I don't know if that's because my configuration isn't working or because my ansible.cfg file isn't even getting picked up at all.
How can I verify whether my ansible.cfg is working?
Q: "I don't know if my configuration isn't working or my ansible.cfg file isn't even getting picked up at all."
A: Run the command
shell> ansible-config dump --only-changed
This will "Only show configurations that have changed from the default" and will also reveal the source of the change either it's a configuration file or an environment variable.
For details see Configuration settings.
Related
I have many playbooks and I don't have access the where Ansible is installed. I can write my playbooks locally on my laptop then I push them to a repo and I can run them via Jenkins. I can't control or change e.g. ansible.cfg or so. Is there a way to manipulate the ansible default stdout callback plugin per playbook without accessing the ansible host itself?
Actually it is, you can use Environmental variable for this: check documentation
ANSIBLE_DISPLAY_SKIPPED_HOSTS=yes ansible-playbook main.yml
But for obvious reasons (It's deprecated) it's better to use the ansible.cfg option for this.
[defaults]
display_skipped_hosts = False
Is it possible to make ansible first search for .ansible.cfg in current directory, instead of always defaulting to home directory? Similarly like many configs work, where it looks in your current dir, then parent (and so on) to find relevant config.
Yet with ansible it always uses config from one place.
When I started deploying with different inventory in mind, I forgot about that, thinking that it will use my local config (where I set path to another inventory, different roles etc), but it of course it used default options and deployed in wrong environments, wrong things..
Is there a way to properly manage multiple configs with ansible?
Say I have dir my-ansible and in that dir, I have .ansible.cfg, so doing cd my-ansible and ansible-playbook my-playbook.yml it would use config in that directory, not in my home dir?
You should use ansible.cfg, not .ansible.cfg in current directory, see
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#the-configuration-file
Changes can be made and used in a configuration file which will be searched for in the following order:
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg
There is a configuration file of repository in %path_of_repo%\.hg\hgrc
It has the following configuration:
[paths]
default = C:\STORAGE\REPOSITORIES\PROJ_FIRST
[web]
name = The First Project
encoding = utf-8
I want change property into conf-file an example. But commands like as:
hg config web.name=NewNameOfProject
It doesn't work (
What is the correct syntax for a command that edits parameters from the Hg Mercurial console? Thx
If I have understood your question correctly, it is asking how to use the Mercurial command-line modify its configuration files.
As far as I am aware, you have to edit the config files manually.
Its a little hard to prove that you "can't" do something... but looking at documentation etc. there are a few things which seem to corroborate this impression.
From hg help config:
Files ...
Mercurial reads configuration data from several files, if they exist.
These files do not exist by default and you will have to create the
appropriate configuration files yourself
From hg config --help:
hg config [-u] [NAME]...
show combined config settings from all hgrc files ...
With --edit, start an editor on the user-level config file. With --global,
edit the system-wide config file. With --local, edit the repository-level
config file.
Furthermore all the other instructions for hg config only explain how to get it to display configuration information, not how to modify it.
Using TortoiseHG, obviously in its File > Settings GUI it will allow you to modify certain values in the config files; but there is no general capability to modify any arbitrary value.
THG however does have a nice built-in editor for those files which is at least convenient to use.
So for web.name you would probably use the per-repository <repo>/.hg/hgrc file. It should include:
...
[web]
name=NewNameOfProject
...
for your example.
I'm using Ansible 2.8 version and i do not see .retry files getting created if the playbook fails to execute tasks on servers.
I do not see any error message as such
Entries in ansible.cfg are as below.
Since the retry_files_enabled defaults to true i have not made any changes to cfg file. Does anyone know the reason why it isnt creating .retry files?
#retry_files_enabled = False
#retry_files_save_path = ~/.ansible-retry
You can check the actual values of configuration by running
ansible-config dump
The reason the Ansible behavior is different from the value in a configuration file is that Ansible have few possible places to look for configuration files, and some of them may have higher preference than your. (f.e. ansible.cfg in the directory with the playbook).
The default behaviour was changed via this proposal:
https://github.com/ansible/proposals/issues/155
RETRY_FILES_ENABLED now defaults to False
Remote host throws error while running Ansible playbook despite a user being sudo user.
"/usr/bin/python: can't open file '/home/ludd/.ansible/tmp/ansible-tmp-1466162346.37-16304304631529/zypper'
A fix that worked for me, was to change the path of the ansible's remote_tmp directory, in ansible's configuration file, e.g.
# /etc/ansible/ansible.cfg
remote_tmp = /tmp/${USER}/ansible
Detailed information can be found here.
Note: With ansible v4 (or later) this this variable might look like this ansible_remote_tmp check the docs
Caution:Ansible Configuration Settings can be declared and used in a configuration file which will be searched for in the following order:
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg
I had to set variable ansible_remote_tmp rather than remote_tmp in order to make it working.
Changing remote_tmp didn't solve the issue for me. What did solve it, however, was removing --connection=local from the playbook invocation.
How does the file in question get to the host? Do you copy or sync it? If you do, may want do to do
chmod 775 fileName
on the file before you send it to the host.