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

36 views
Skip to first unread message

Arc Tangente

unread,
Mar 3, 2022, 12:50:05 PM3/3/22
to Ansible Project

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 db configuration"
 hosts: db
 gather_facts: no
 tags: [ "mariadb", "mysql" ]
 roles:
   - role: "mediawiki/confdb"

- name: "MediaWiki apache configuration"
 hosts: apache
 gather_facts: no
 tags: "apache"
 roles:
   - role: "mediawiki/confapache"

The role mediawiki/confapache/tasks/main.yml:
(ansible2.7.10) user-ansible@node-manager:~$ cat roles/mediawiki/confapache/tasks/main.yml
# ~/roles/mediawiki/confapache/tasks/main.yml
---

#1. Creation of the directory Mediawiki
- name: "mediawiki directory"      
 file:
   path: "{{mediawiki_directory}}"     # => /var/www/html/mediawiki
   owner: "apache"
   group: "apache"
   state: directory

#2. Unarchiving of the archive Mediawiki and change the name
- name: "uncompress mediawiki archive"
 unarchive:
   src: "{{mediawiki_archive_url}}"    # => https://releases… …/mediawiki/1.31/mediawiki-1.31.1.tar.gz
   dest: "{{mediawiki_directory}}"     # => /var/www/html/mediawiki
   owner: "apache"
   group: "apache"
   remote_src: yes
     # delete mediawiki-1.xx.x/ in the filesname
   extra_opts: --transform=s/mediawiki-[0-9\.]*\///

#3. executes the task with the user apache, we move in the diectory maintenance if
 localsetting.php doesn't exist.
- 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}}"

#4. executes this task with the user apache, we move to the directory 'maintenance' and execute a command to udate.
jour de la base une seule fois
- name: "mediawiki db update"
 become: yes
 become_user: "apache"
 command: php update.php --quick
 args:
   chdir: "{{mediawiki_maintenance_directory}}"            # => /var/www/html/mediawiki/maintenance (contient install.php
!!)
 run_once: yes
 register: resultat
 changed_when: "' ...done.' in resultat.stdout"

And then the issue:
(ansible2.7.10) user-ansible@node-manager:~$ ansible-playbook -i inventaire.ini --user user-ansible --become --ask-become-pass --ask-vault-pass install-mediawiki.yml          
SUDO password:  
Vault password:  

PLAY [mediaWiki db configuration] *********************************************************************************************************************************************************************************************************************

TASK [mediawiki/confdb : mediawiki database] **********************************************************************************************************************************************************************************************************
ok: [bdd2]

TASK [mediawiki/confdb : mediawiki user+privileges] ***************************************************************************************************************************************************************************************************
ok: [bdd2] => (item=['http2'])

PLAY [MediaWiki apache configuration] *****************************************************************************************************************************************************************************************************************

TASK [mediawiki/confapache : mediawiki directory] *****************************************************************************************************************************************************************************************************
ok: [http2]

TASK [mediawiki/confapache : uncompress mediawiki archive] ********************************************************************************************************************************************************************************************
ok: [http2]

TASK [mediawiki/confapache : mediawiki configuration] *************************************************************************************************************************************************************************************************
failed: [http2] (item=['http2']) => {"item": "['http2']", "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ['http2']: Name or service not known", "unreachable": true}
fatal: [http2]: UNREACHABLE! => {"changed": false, "msg": "All items completed", "results": [{"_ansible_ignore_errors": null, "_ansible_item_label": "['http2']", "_ansible_item_result": true, "item": "['http2']", "msg": "Failed to connect to the h
ost via ssh: ssh: Could not resolve hostname ['http2']: Name or service not known", "unreachable": true}]}


NO MORE HOSTS LEFT ************************************************************************************************************************************************************************************************************************************
       to retry, use: --limit @/home/user-ansible/install-mediawiki.retry

PLAY RECAP ********************************************************************************************************************************************************************************************************************************************
bdd2                       : ok=2    changed=0    unreachable=0    failed=0    
http2                      : ok=2    changed=0    unreachable=1    failed=0


Why is the node http2 suddently unreachable, although it was reachable ?

Thanks for your help.


dulh...@mailbox.org

unread,
Mar 3, 2022, 2:59:43 PM3/3/22
to ansible...@googlegroups.com


- 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?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/af9c5cbf-a6b6-4e5a-a275-12fec56c0116n%40googlegroups.com.

dulh...@mailbox.org

unread,
Mar 4, 2022, 5:46:24 AM3/4/22
to ansible...@googlegroups.com
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)




On 04.03.22 09:44, Arc Tangente wrote:
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'.

Arc Tangente

unread,
Mar 4, 2022, 6:17:18 AM3/4/22
to Ansible Project
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'.


Le jeudi 3 mars 2022 à 20:59:43 UTC+1, dulh...@mailbox.org a écrit :

Rajthecomputerguy

unread,
Mar 4, 2022, 9:53:05 PM3/4/22
to ansible...@googlegroups.com
you can try in separate yaml file 

***********************************************************************************************************************
mediawiki_config.yaml
- 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
****************************************************************************************************************************************************

- name:  "mediawiki configuration"
  include:  mediawiki_config.yaml
  delegate_to: '{{ item }}'
  with_items: "{{ groups.apache }}"

Arc Tangente

unread,
Mar 8, 2022, 6:36:35 AM3/8/22
to Ansible Project
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 :)

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.
Reply all
Reply to author
Forward
0 new messages