From 7d2d084bd40754042773d36e028be688c4894490 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Tue, 21 Apr 2015 09:53:26 +0200 Subject: [PATCH] Aggiunta Vagrantfile. Gestione riconfigurazione pochi servizi di nethserver. --- .gitignore | 1 - Vagrantfile | 129 ++++++++++++++++++++++++ roles/init/tasks/configure-networks.yml | 13 +++ roles/init/tasks/main.yml | 4 + roles/setup/tasks/centos_pkgs.yml | 11 +- roles/setup/tasks/main.yml | 4 + roles/setup/tasks/neth_config.yml | 6 ++ 7 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 Vagrantfile create mode 100644 roles/init/tasks/configure-networks.yml create mode 100644 roles/setup/tasks/neth_config.yml diff --git a/.gitignore b/.gitignore index 9920c54..fc2671f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ *.swp *.box -Vagrantfile .vagrant/* diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..6f14ba6 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,129 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "nethserver" + config.vm.define "NethServer" do |nethserver| + end + config.vm.provider :virtualbox do |vb| + vb.name = "NethServer" + end + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + config.vm.network "forwarded_port", guest: 980, host: 9800 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + config.vm.network "public_network", ip: "10.0.0.1" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/roles/init/tasks/configure-networks.yml b/roles/init/tasks/configure-networks.yml new file mode 100644 index 0000000..156c41d --- /dev/null +++ b/roles/init/tasks/configure-networks.yml @@ -0,0 +1,13 @@ +--- +- name: Verifica di NethServer + shell: /sbin/e-smith/config getprop sysconfig ProductName + register: sysconfig_productname + +- name: Configuro la scheda secondaria + shell: /sbin/e-smith/db networks setprop eth1 bootproto none device eth1 ipaddr 10.0.0.1 netmask 255.255.255.0 onboot yes role green + when: "'NethServer' in sysconfig_productname.stdout" + register: eth1_enabled + +- name: Attivo la configurazione + shell: signal-event interface-update + when: eth1_enabled|success diff --git a/roles/init/tasks/main.yml b/roles/init/tasks/main.yml index 82a86d5..ec391c2 100644 --- a/roles/init/tasks/main.yml +++ b/roles/init/tasks/main.yml @@ -1,5 +1,9 @@ --- +# solo se รจ virtualbox, procedo a configurare la seconda scheda di rete +- include: configure-networks.yml + when: ansible_bios_version == "VirtualBox" + - include: selinux-binding.yml - include: mgmtuser.yml diff --git a/roles/setup/tasks/centos_pkgs.yml b/roles/setup/tasks/centos_pkgs.yml index a61197d..dedde02 100644 --- a/roles/setup/tasks/centos_pkgs.yml +++ b/roles/setup/tasks/centos_pkgs.yml @@ -23,16 +23,21 @@ - name: Abilito il repo EPEL shell: yum-config-manager --enable epel sudo: yes - when: epel_installed|success or rpm_epel_installed|success - changed_when: epel_enabled.rc == 0 + when: epel_installed|changed or rpm_epel_installed|changed + changed_when: "'[epel]' in epel_enabled.stdout and epel_enabled.rc == 0" register: epel_enabled - name: Pulizia e ricaricam. repo shell: yum clean all && yum repolist sudo: yes - when: epel_enabled|success + when: check_epel|failed and epel_enabled|changed tags: repo +- name: Aggiorno il sistema + yum: name=* state=latest + sudo: yes + tags: upgrade + - name: Installo pacchetti addizionali yum: name={{ item }} state=present sudo: yes diff --git a/roles/setup/tasks/main.yml b/roles/setup/tasks/main.yml index 7675a30..76710e9 100644 --- a/roles/setup/tasks/main.yml +++ b/roles/setup/tasks/main.yml @@ -13,3 +13,7 @@ - include: neth_pkgs.yml when: ansible_distribution == "CentOS" and ansible_os_family == "RedHat" tags: neth + +- include: neth_config.yml + when: ansible_distribution == "CentOS" and ansible_os_family == "RedHat" + tags: neth diff --git a/roles/setup/tasks/neth_config.yml b/roles/setup/tasks/neth_config.yml new file mode 100644 index 0000000..c88d94d --- /dev/null +++ b/roles/setup/tasks/neth_config.yml @@ -0,0 +1,6 @@ +--- +# Configurazioni a quanto pare non fattibili dall'interfaccia +- name: Configuro il servizio DNS come resolver + shell: /sbin/e-smith/db configuration setprop dns role resolver NameServers 208.67.222.222,208.67.220.220 + sudo: yes + tags: dns