diff --git a/domain.yml b/domain.yml index fad1043..c71e511 100644 --- a/domain.yml +++ b/domain.yml @@ -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/ diff --git a/mirror.yml b/mirror.yml deleted file mode 100644 index a11d20b..0000000 --- a/mirror.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -use_local_mirror: true -mirror_nfs: 192.168.255.1:/var/spool/apt-mirror/mirror diff --git a/roles/nethcfg/defaults/main.yml b/roles/nethcfg/defaults/main.yml index 0e8c0a1..29968c7 100644 --- a/roles/nethcfg/defaults/main.yml +++ b/roles/nethcfg/defaults/main.yml @@ -1,3 +1,4 @@ --- extnic: wan0 intnic: lan0 +force_regen_ca: false diff --git a/roles/preseed/defaults/main.yml b/roles/preseed/defaults/main.yml new file mode 100644 index 0000000..32b0575 --- /dev/null +++ b/roles/preseed/defaults/main.yml @@ -0,0 +1,2 @@ +--- +execmirrorpath: "" diff --git a/roles/preseed/tasks/main.yml b/roles/preseed/tasks/main.yml index 9b045ce..e8ba54c 100644 --- a/roles/preseed/tasks/main.yml +++ b/roles/preseed/tasks/main.yml @@ -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 diff --git a/roles/preseed/templates/ansible-ansible-trusty.list b/roles/preseed/templates/ansible-ansible-trusty.list index b3a40a2..bef18f0 100644 --- a/roles/preseed/templates/ansible-ansible-trusty.list +++ b/roles/preseed/templates/ansible-ansible-trusty.list @@ -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 diff --git a/roles/preseed/templates/libreoffice-5-trusty.list b/roles/preseed/templates/libreoffice-5-trusty.list index 1e745a8..5776f5b 100644 --- a/roles/preseed/templates/libreoffice-5-trusty.list +++ b/roles/preseed/templates/libreoffice-5-trusty.list @@ -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 diff --git a/roles/preseed/templates/preseed/client-trusty.seed b/roles/preseed/templates/preseed/client-trusty.seed index 8cee4fd..c10acdc 100644 --- a/roles/preseed/templates/preseed/client-trusty.seed +++ b/roles/preseed/templates/preseed/client-trusty.seed @@ -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 diff --git a/roles/preseed/templates/preseed/docenti-trusty.seed b/roles/preseed/templates/preseed/docenti-trusty.seed index 59ea0f6..f1dd799 100644 --- a/roles/preseed/templates/preseed/docenti-trusty.seed +++ b/roles/preseed/templates/preseed/docenti-trusty.seed @@ -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 diff --git a/roles/preseed/templates/preseed/edubuntu.seed b/roles/preseed/templates/preseed/edubuntu.seed index 4978980..4a75d41 100644 --- a/roles/preseed/templates/preseed/edubuntu.seed +++ b/roles/preseed/templates/preseed/edubuntu.seed @@ -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 diff --git a/roles/ubuntu-mirror/defaults/main.yml b/roles/ubuntu-mirror/defaults/main.yml new file mode 100644 index 0000000..32b0575 --- /dev/null +++ b/roles/ubuntu-mirror/defaults/main.yml @@ -0,0 +1,2 @@ +--- +execmirrorpath: "" diff --git a/roles/ubuntu-mirror/tasks/local-mirror.yml b/roles/ubuntu-mirror/tasks/local-mirror.yml index e1022e5..0af1560 100644 --- a/roles/ubuntu-mirror/tasks/local-mirror.yml +++ b/roles/ubuntu-mirror/tasks/local-mirror.yml @@ -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 diff --git a/roles/ubuntu-mirror/tasks/main.yml b/roles/ubuntu-mirror/tasks/main.yml index 3babb49..6abeef2 100644 --- a/roles/ubuntu-mirror/tasks/main.yml +++ b/roles/ubuntu-mirror/tasks/main.yml @@ -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 diff --git a/roles/ubuntu-mirror/tasks/nfs-mirror.yml b/roles/ubuntu-mirror/tasks/nfs-mirror.yml new file mode 100644 index 0000000..26fa5f1 --- /dev/null +++ b/roles/ubuntu-mirror/tasks/nfs-mirror.yml @@ -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 diff --git a/roles/ubuntu-mirror/tasks/remote-mirror.yml b/roles/ubuntu-mirror/tasks/remote-mirror.yml new file mode 100644 index 0000000..32eafa8 --- /dev/null +++ b/roles/ubuntu-mirror/tasks/remote-mirror.yml @@ -0,0 +1,3 @@ +--- +# Managing a remote mirror - Doing nothing ;) + diff --git a/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml b/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml deleted file mode 100644 index 0af1560..0000000 --- a/roles/ubuntu-mirror/tasks/ubuntu-mirror.yml +++ /dev/null @@ -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 diff --git a/run.sh b/run.sh index c8399cb..e762b5c 100755 --- a/run.sh +++ b/run.sh @@ -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 diff --git a/setup.yml b/setup.yml index 155793c..ef8fe44 100644 --- a/setup.yml +++ b/setup.yml @@ -1,8 +1,6 @@ --- - hosts: server - vars_files: - - mirror.yml roles: - setup - nethcfg