- name: "mediawiki directory" 
  file: 
    path: "{{mediawiki_directory}}" 
    owner: "apache" 
    group: "apache" 
    state: directory 
 
- name: "uncompress mediawiki archive" 
  unarchive: 
    src: "{{mediawiki_archive_url}}" 
    dest: "{{mediawiki_directory}}" 
    owner: "apache" 
    group: "apache" 
    # unpack an archive which already exists on the targe
    remote_src: yes 
    # remove mediawiki-1.xx.x/ from path 
    extra_opts: --transform=s/mediawiki-[0-9\.]*\/// 
- name: "mediawiki configuration" 
  become: yes 
  become_user: "apache" 
  args:
   creates: "{{mediawiki_directory}}/LocalSettings.php"
   chdir: "{{mediawiki_maintenance_directory}}"
  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}} {{mediawiki_admin_user}}

- name: "uncompress mediawiki skins"
  unarchive:
    src: "{{mediawiki_skins_url}}"
    dest: "{{mediawiki_directory}}/skins"
    owner: "apache"
    group: "apache"
    # unpack an archive which already exists on the targe
    remote_src: yes

- name: "ajuste LocalSettings.php skins"
  ansible.builtin.lineinfile:
    path: "{{mediawiki_directory}}/LocalSettings.php"
    line: wfLoadSkin( 'MonoBook' );

- name: "ajuste LocalSettings.php Server"
  ansible.builtin.lineinfile:
    path: "{{mediawiki_directory}}/LocalSettings.php"
    search_string: '$wgServer'
    line: $wgServer = "http://{{inventory_hostname}}";

- name: "ajuste LocalSettings.php Skins"
  ansible.builtin.lineinfile:
    path: "{{mediawiki_directory}}/LocalSettings.php"
    search_string: 'wgDefaultSkin'
    line: $wgDefaultSkin = "MonoBook";
