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 }}"

On Thu, Mar 3, 2022 at 11:20 PM Arc Tangente <arctange...@gmail.com> 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-project+unsubscr...@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/CAE5Yv1RMjK1C2Hu_VGPfvF6JFiUJEzavznS70mV%2BawtZ9bSBQg%40mail.gmail.com.

Reply via email to