aboutsummaryrefslogtreecommitdiffstats
path: root/roles/yum_mirror/tasks/main.yml
blob: 2e00d17d682fd50ad5e9d0952c2c01f158014fb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
- name: install packages
  dnf:
    name: yum-utils
    state: present

- name: create repo definitions
  yum_repository:
    name: '{{ item.id }}'
    file: mirrors
    description: '{{ item.name }}'
    metalink: '{{ item.metalink | default(omit) }}'
    mirrorlist: '{{ item.mirrorlist | default(omit) }}'
    baseurl: '{{ item.baseurl | default(omit) }}'
    gpgcheck: no
    enabled: no
    state: present
  loop: '{{ yum_mirror_repositories }}'

- name: create repo directories
  file:
    path: '{{ yum_mirror_webroot }}/{{ item.path }}'
    state: directory
    recurse: yes
    setype: _default
  loop: '{{ yum_mirror_repositories }}'

- name: generate reposync cron script
  template:
    src: '{{ yum_mirror_reposync_script[1:] }}.j2'
    dest: '{{ yum_mirror_reposync_script }}'
    mode: 0555

- name: set up reposync timer
  include_role:
    name: systemd_timer
  vars:
    timer_name: reposync
    timer_description: Sync yum mirrors from upstream
    timer_after: network.target
    timer_on_calendar: '{{ yum_sync_on_calendar }}'
    timer_exec: '{{ yum_mirror_reposync_script }}'

- name: sync repositories
  systemd:
    name: reposync.service
    state: started
  changed_when: no