The name of a node is not resolved after it was resolved ?

Hello,

I start this playbook install-mediawiki.yml, the first role is executed without problems.

The second role has 4 tasks, executed fully the 2 first of them, but has suddently an issue: the name of the node is not resolved anymore.
I do not know why.

I have installed ansible in a virtual python environment and
defines the inventory so:
(ansible2.7.10) user-ansible@node-manager:~$ cat inventaire.ini
[apache]
http2

[db]
bdd2

/etc/hosts in each node contains this:
(ansible2.7.10) user-ansible@node-manager:~$ cat /etc/hosts

192.168.0.103 http2
192.168.0.104 bdd2

The SSH connexion works withe key, the public keys are in the nodes…

Here is a ping test:
(ansible2.7.10) user-ansible@node-manager:~$ ansible -i inventaire.ini all -m ping
bdd2 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
http2 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}

The playbook:
(ansible2.7.10) user-ansible@node-manager:~$ cat install-mediawiki.yml

  • name: “mediawiki configuration”
    become: yes
    become_user: “apache”
    args:
    creates: “{{mediawiki_directory}}/LocalSettings.php” # => /var/www/html/mediawiki/LocalSettings.php
    chdir: “{{mediawiki_maintenance_directory}}” # => /var/www/html/mediawiki/maintenance (contient install.php !!)
    command:
    php install.php --scriptpath /{{mediawiki_name}} --dbname mediawiki --lang fr --dbuser {{mediawiki_db_user}} --dbpass {{mediawiki_db_password}} --pass {{mediawiki_admin_password}} --dbserver {{mediawiki_db_host}} {{mediawiki_title}} {{mediawi
    ki_admin_user}}
    run_once: yes
    delegate_to: “{{item}}”
    with_items: “{{groups.apache}}”

have you tried loop instead of with_items? something like:


run_once: yes
delegate_to: “{{item}}”
loop:
- “{{groups.apache}}”

if I am not mistaken with_items is deprecated?

also the indentation looks a bit suspicious, or is that just the email formatting?

sorry to hear the loop did not help.
Generally I believe it is better to reply to the group and not to the correspondent personally (probably not even intended)

Hi,
Thanks for your help.

I changed ‘with_items’ for ‘loop’, as proposed. It does not resolve the issue.
By the way ‘with_items’ works well in another task in another role.

About the indentation, it is because of the email formating… (sorry)

‘become, become_user, args, command, run_once, delegate_to and with_items’ are aligned with ‘name’ (not with - )
‘creates and chdir’ have two more spaces compared to ‘args’.

you can try in separate yaml file

Hi,
thanks. I have searched a lot these past days for a solution.

I have installed ansible in another VM, Ubuntu 20.04, as sshpass with apt. I configured everything, so that the first part of network works. I have also this time configured /etc/ansible/hosts, therefor I didn’t use -i inventaire.ini any more in the cli (ad-oc). Before, I didn’t have this file, because I was in a virtual python environment.

The result is positive, it works well. I can now access to mediawiki through a web browser :slight_smile:

I will make a try with your proposal, but a bit later. I am a beginner, follow a tutorial and want learn further…

Have a nice day.