Committing changes for mirror mode selection.

This commit is contained in:
Emiliano Vavassori 2015-11-04 23:52:57 +01:00
parent 5c7e912cd4
commit 28b4aa5f75
18 changed files with 98 additions and 74 deletions

View File

@ -20,4 +20,6 @@ org_department: "Laboratorio 1"
org_city: Caravaggio
org_phone: "+39 0363 50598"
org_street: "Via Zenale e Butinone, 20"
mirror_mode: nfs
mirror_nfs_share: 192.168.255.1:/var/spool/apt-mirror/mirror
mirrorpath: pdc.mastri.edu/ks/mirror/

View File

@ -1,3 +0,0 @@
---
use_local_mirror: true
mirror_nfs: 192.168.255.1:/var/spool/apt-mirror/mirror

View File

@ -1,3 +1,4 @@
---
extnic: wan0
intnic: lan0
force_regen_ca: false

View File

@ -0,0 +1,2 @@
---
execmirrorpath: ""

View File

@ -1,4 +1,10 @@
---
- name: Configuring executive mirror path
set_fact:
execmirrorpath: "{{ ansible_local.domain.mirrorpath }}"
when: ansible_local.domain.mirror_mode == 'nfs' or ansible_local.domain.mirror_mode == 'local'
- include: preseed.yml
tags:
- preseed

View File

@ -1,2 +1,2 @@
deb http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
# deb-src http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
deb http://{{ execmirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
# deb-src http://{{ execmirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main

View File

@ -1,2 +1,2 @@
deb http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
deb-src http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
deb http://{{ execmirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
deb-src http://{{ execmirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main

View File

@ -38,12 +38,12 @@ d-i apt-setup/security_host string {{ ansible_local.domain.serverfqdn }}
d-i apt-setup/security_path string /ks/mirror/security.ubuntu.com/ubuntu
# Setup and enable libreoffice PPA
d-i apt-setup/local0/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/repository string http://{{ execmirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/comment string LibreOffice Official PPA
d-i apt-setup/local0/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x36E81C9267FD1383FCC4490983FBA1751378B444&op=get
# Setup and enable ansible PPA
d-i apt-setup/local1/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/repository string http://{{ execmirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/comment string Ansible Official PPA
d-i apt-setup/local1/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367&op=get

View File

@ -38,12 +38,12 @@ d-i apt-setup/security_host string {{ ansible_local.domain.serverfqdn }}
d-i apt-setup/security_path string /ks/mirror/security.ubuntu.com/ubuntu
# Setup and enable libreoffice PPA
d-i apt-setup/local0/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/repository string http://{{ execmirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/comment string LibreOffice Official PPA
d-i apt-setup/local0/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x36E81C9267FD1383FCC4490983FBA1751378B444&op=get
# Setup and enable ansible PPA
d-i apt-setup/local1/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/repository string http://{{ execmirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/comment string Ansible Official PPA
d-i apt-setup/local1/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367&op=get

View File

@ -39,12 +39,12 @@ d-i apt-setup/security_host string {{ ansible_local.domain.serverfqdn }}
d-i apt-setup/security_path string /ks/mirror/security.ubuntu.com/ubuntu
# Setup and enable libreoffice PPA
d-i apt-setup/local0/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/repository string http://{{ execmirrorpath }}ppa.launchpad.net/libreoffice/libreoffice-5-0/ubuntu trusty main
d-i apt-setup/local0/comment string LibreOffice Official PPA
d-i apt-setup/local0/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x36E81C9267FD1383FCC4490983FBA1751378B444&op=get
# Setup and enable ansible PPA
d-i apt-setup/local1/repository string http://{{ ansible_local.domain.mirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/repository string http://{{ execmirrorpath }}ppa.launchpad.net/ansible/ansible/ubuntu trusty main
d-i apt-setup/local1/comment string Ansible Official PPA
d-i apt-setup/local1/key string http://keyserver.ubuntu.com:11371/pks/lookup?search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367&op=get

View File

@ -0,0 +1,2 @@
---
execmirrorpath: ""

View File

@ -1,36 +1,18 @@
---
# Managing when there's a local mirror served via NFS
# Configurazione del server come repo
- name: Adding required packages
yum:
name: "{{ item }}"
state: present
with_items:
- nfs-utils
- nfs-utils-lib
- name: Installazione apt-mirror
yum: pkg=apt-mirror state=present
sudo: yes
- name: Checking if already mounted
shell: mount | grep -q "{{ mirror_nfs }}" && echo "Mounted" || true
register: chk_mount_nfs
changed_when: "'Mounted' not in chk_mount_nfs.stdout"
- name: Installazione configurazione apt-mirror
copy: src=apt-mirror.list dest=/etc/apt-mirror.list
sudo: yes
- name: Installazione cron per sincronizzazione notturna
copy: src=apt-mirror-cron dest=/etc/cron.daily/apt-mirror mode=0755
sudo: yes
- name: Creating mountpoint directory
file:
path: /var/spool/apt-mirror/mirror
recurse: yes
state: directory
owner: root
group: root
mode: 0755
when: chk_mount_nfs|changed
- name: Adding mountpoint to fstab
lineinfile:
dest: /etc/fstab
line: "{{ mirror_nfs }} /var/spool/apt-mirror/mirror nfs4 defaults 0 0"
when: chk_mount_nfs|changed
- name: Mounting share
shell: mount /var/spool/apt-mirror/mirror
when: chk_mount_nfs|changed
- name: Installazione logrotate per sincronizzazione notturna
copy: src=apt-mirror-logrotate dest=/etc/logrotate.d/apt-mirror mode=0644
sudo: yes

View File

@ -1,9 +1,26 @@
---
- include: ubuntu-mirror.yml
when: not use_local_mirror|bool
tags: ubuntu-mirror
- name: Configuring executive mirrorpath
set_fact:
execmirrorpath: "{{ ansible_local.domain.mirrorpath }}"
when: ansible_local.domain.mirror_mode == 'local' or ansible_local.domain.mirror_mode == 'nfs'
- include: local-mirror.yml
when: use_local_mirror|bool
when: ansible_local.domain.mirror_mode == 'local'
tags:
- mirror
- local-mirror
- include: nfs-mirror.yml
when: ansible_local.domain.mirror_mode == 'nfs'
sudo: yes
tags: local-mirror
tags:
- mirror
- nfs-mirror
- include: remote-mirror.yml
when: ansible_local.domain.mirror_mode == 'remote'
sudo: yes
tags:
- mirror
- remote-mirror

View File

@ -0,0 +1,36 @@
---
# Managing when there's a local mirror served via NFS
- name: Adding required packages
yum:
name: "{{ item }}"
state: present
with_items:
- nfs-utils
- nfs-utils-lib
- name: Checking if already mounted
shell: mount | grep -q "{{ ansible_local.domain.mirror_nfs_share }}" && echo "Mounted" || true
register: chk_mount_nfs
changed_when: "'Mounted' not in chk_mount_nfs.stdout"
- name: Creating mountpoint directory
file:
path: /var/spool/apt-mirror/mirror
recurse: yes
state: directory
owner: root
group: root
mode: 0755
when: chk_mount_nfs|changed
- name: Adding mountpoint to fstab
lineinfile:
dest: /etc/fstab
line: "{{ ansible_local.domain.mirror_nfs_share }} /var/spool/apt-mirror/mirror nfs4 defaults 0 0"
when: chk_mount_nfs|changed
- name: Mounting share
shell: mount /var/spool/apt-mirror/mirror
when: chk_mount_nfs|changed

View File

@ -0,0 +1,3 @@
---
# Managing a remote mirror - Doing nothing ;)

View File

@ -1,18 +0,0 @@
---
# Configurazione del server come repo
- name: Installazione apt-mirror
yum: pkg=apt-mirror state=present
sudo: yes
- name: Installazione configurazione apt-mirror
copy: src=apt-mirror.list dest=/etc/apt-mirror.list
sudo: yes
- name: Installazione cron per sincronizzazione notturna
copy: src=apt-mirror-cron dest=/etc/cron.daily/apt-mirror mode=0755
sudo: yes
- name: Installazione logrotate per sincronizzazione notturna
copy: src=apt-mirror-logrotate dest=/etc/logrotate.d/apt-mirror mode=0644
sudo: yes

6
run.sh
View File

@ -8,10 +8,6 @@ echo "Please review settings for domain/server settings."
sleep 2
$EDITOR domain.yml
echo "Please review mirror settings from mirror.yml."
sleep 2
$EDITOR mirror.yml
# Configure the server machine using Ansible tasks.
ansible-playbook init.yml --ask-pass
ansible-playbook init.yml --ask-pass -e admin_sshkey=$HOME/.ssh/id_rsa.pub
ansible-playbook setup.yml

View File

@ -1,8 +1,6 @@
---
- hosts: server
vars_files:
- mirror.yml
roles:
- setup
- nethcfg