sorry to hear the loopdid 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'.
Le jeudi 3 mars 2022 à 20:59:43 UTC+1, dulh...@mailbox.org a écrit :
- 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?
On 03.03.22 11:46, Arc Tangente wrote:
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*_:
(some informations about install.php
<https://www.mediawiki.org/wiki/Topic:Tnwigdax8a5vc9po>)
(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.
--
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
<https://groups.google.com/d/msgid/ansible-project/af9c5cbf-a6b6-4e5a-a275-12fec56c0116n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bfc27427-c6f3-5033-061c-cff22733e5c9%40mailbox.org.