From 410a9c480d9250feed43c89ee5dfa96347aeeccf Mon Sep 17 00:00:00 2001 From: Xicheng Chang Date: Sat, 18 Apr 2015 00:09:12 -0700 Subject: [PATCH] Fix hardcode for ubuntu apt-key patch2: make ansible code follow lint. patch2: some of the 'shell' command will be replaced with ansible built-in 'script' in a separate CL. Change-Id: I010fbf89d7393c2ba1bee06dca36196fe5cc7006 --- ansible/openstack_juno/group_vars/all | 1 + .../roles/cinder-volume/tasks/main.yml | 11 +++--- .../roles/common/tasks/main.yml | 10 +++--- .../roles/dashboard/tasks/main.yml | 3 +- .../roles/database/tasks/main.yml | 2 +- .../roles/glance/tasks/main.yml | 3 +- .../roles/neutron-compute/tasks/main.yml | 19 +++++++---- .../roles/neutron-network/tasks/main.yml | 34 +++++++++++++------ 8 files changed, 55 insertions(+), 28 deletions(-) diff --git a/ansible/openstack_juno/group_vars/all b/ansible/openstack_juno/group_vars/all index 3911053..5643fcd 100644 --- a/ansible/openstack_juno/group_vars/all +++ b/ansible/openstack_juno/group_vars/all @@ -40,6 +40,7 @@ EXTERNAL_NETWORK_GATEWAY: 203.0.113.1 FLOATING_IP_START: 203.0.113.101 FLOATING_IP_END: 203.0.113.200 +juno_cloud_archive: deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/juno main build_in_image: http://cdn.download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img build_in_image_name: cirros-0.3.3-x86_64-disk.img diff --git a/ansible/openstack_juno/roles/cinder-volume/tasks/main.yml b/ansible/openstack_juno/roles/cinder-volume/tasks/main.yml index c8e8f5e..d29e94f 100644 --- a/ansible/openstack_juno/roles/cinder-volume/tasks/main.yml +++ b/ansible/openstack_juno/roles/cinder-volume/tasks/main.yml @@ -9,7 +9,7 @@ stat: path={{ physical_device }} register: st -- name: repace physical_device with /dev/loop if st returns false +- name: repace physical_device if st is false local_action: copy src=loop.yml dest=/tmp/loop.yml when: st.stat.exists == False @@ -26,7 +26,8 @@ register: partition_size - name: if not mounted, mount it - shell: dd if=/dev/zero of=/mnt/cinder-volumes bs=1 count=0 seek={{ partition_size.stdout }} + shell: dd if=/dev/zero of=/mnt/cinder-volumes + bs=1 count=0 seek={{ partition_size.stdout }} when: cindervolumes.stdout != 'cinder-volumes' - name: get first lo device @@ -39,10 +40,12 @@ when: cindervolumes.stdout != 'cinder-volumes' - name: create physical and group volumes - lvg: vg=cinder-volumes pvs={{ physical_device }} vg_options=--force + lvg: vg=cinder-volumes pvs={{ physical_device }} + vg_options=--force - name: upload cinder-volume configuration - template: src=cinder.conf dest=/etc/cinder/cinder.conf backup=yes + template: src=cinder.conf dest=/etc/cinder/cinder.conf + backup=yes notify: - restart cinder-volume - restart tgt diff --git a/ansible/openstack_juno/roles/common/tasks/main.yml b/ansible/openstack_juno/roles/common/tasks/main.yml index eacf656..cdd585b 100644 --- a/ansible/openstack_juno/roles/common/tasks/main.yml +++ b/ansible/openstack_juno/roles/common/tasks/main.yml @@ -1,9 +1,11 @@ --- -- name: add juno cloudarchive - apt_repository: repo='deb http://ubuntu-cloud.archive.canonical.com/ubuntu trusty-updates/juno main' state=present +- name: install ubuntu-cloud-keyring(ubuntu) + apt: name={{ item }} state=latest + with_items: + - ubuntu-cloud-keyring -- name: add juno apt key - apt_key: keyserver=keyserver.ubuntu.com id=5EDB1B62EC4926EA +- name: add juno cloudarchive + apt_repository: repo={{ juno_cloud_archive }} state=present - name: update packages once apt: update_cache=yes diff --git a/ansible/openstack_juno/roles/dashboard/tasks/main.yml b/ansible/openstack_juno/roles/dashboard/tasks/main.yml index da975fe..33e6ebf 100644 --- a/ansible/openstack_juno/roles/dashboard/tasks/main.yml +++ b/ansible/openstack_juno/roles/dashboard/tasks/main.yml @@ -19,7 +19,8 @@ # backup=yes - name: update horizon settings - template: src=local_settings.py dest=/etc/openstack-dashboard/local_settings.py + template: src=local_settings.py + dest=/etc/openstack-dashboard/local_settings.py backup=yes - name: restart apache2 diff --git a/ansible/openstack_juno/roles/database/tasks/main.yml b/ansible/openstack_juno/roles/database/tasks/main.yml index 8c0a76c..9da7a83 100644 --- a/ansible/openstack_juno/roles/database/tasks/main.yml +++ b/ansible/openstack_juno/roles/database/tasks/main.yml @@ -12,7 +12,7 @@ notify: - restart mysql -- name: manually restart mysql server first before creating db models +- name: manually restart mysql server service: name=mysql state=restarted diff --git a/ansible/openstack_juno/roles/glance/tasks/main.yml b/ansible/openstack_juno/roles/glance/tasks/main.yml index 31f36c1..32d2ec5 100644 --- a/ansible/openstack_juno/roles/glance/tasks/main.yml +++ b/ansible/openstack_juno/roles/glance/tasks/main.yml @@ -6,7 +6,8 @@ - python-glanceclient - name: update glance conf - template: src={{ item }} dest=/etc/glance/{{ item }} backup=yes + template: src={{ item }} dest=/etc/glance/{{ item }} + backup=yes with_items: - glance-api.conf - glance-registry.conf diff --git a/ansible/openstack_juno/roles/neutron-compute/tasks/main.yml b/ansible/openstack_juno/roles/neutron-compute/tasks/main.yml index dd92be8..39523a9 100644 --- a/ansible/openstack_juno/roles/neutron-compute/tasks/main.yml +++ b/ansible/openstack_juno/roles/neutron-compute/tasks/main.yml @@ -1,13 +1,16 @@ --- - name: activate ipv4 forwarding - sysctl: name=net.ipv4.ip_forward value=1 state=present reload=yes + sysctl: name=net.ipv4.ip_forward value=1 + state=present reload=yes - name: deactivate ipv4 rp filter - sysctl: name=net.ipv4.conf.all.rp_filter value=0 state=present reload=yes + sysctl: name=net.ipv4.conf.all.rp_filter value=0 + state=present reload=yes - name: deactivate ipv4 default rp filter - sysctl: name=net.ipv4.conf.default.rp_filter value=0 state=present reload=yes + sysctl: name=net.ipv4.conf.default.rp_filter + value=0 state=present reload=yes - name: install compute-related neutron packages apt: name={{ item }} state=present force=yes @@ -18,16 +21,20 @@ - openvswitch-switch - name: install neutron openvswitch agent - apt: name=neutron-plugin-openvswitch-agent state=present force=yes + apt: name=neutron-plugin-openvswitch-agent + state=present force=yes when: "'opendaylight' not in {{ NEUTRON_MECHANISM_DRIVERS }}" - name: config neutron - template: src=neutron-network.conf dest=/etc/neutron/neutron.conf backup=yes + template: src=neutron-network.conf + dest=/etc/neutron/neutron.conf backup=yes notify: - restart neutron-plugin-openvswitch-agent - name: config ml2 plugin - template: src=ml2_conf.ini dest=/etc/neutron/plugins/ml2/ml2_conf.ini backup=yes + template: src=ml2_conf.ini + dest=/etc/neutron/plugins/ml2/ml2_conf.ini + backup=yes notify: - restart neutron-plugin-openvswitch-agent diff --git a/ansible/openstack_juno/roles/neutron-network/tasks/main.yml b/ansible/openstack_juno/roles/neutron-network/tasks/main.yml index b3362a9..4a804ef 100644 --- a/ansible/openstack_juno/roles/neutron-network/tasks/main.yml +++ b/ansible/openstack_juno/roles/neutron-network/tasks/main.yml @@ -1,12 +1,15 @@ --- - name: activate ipv4 forwarding - sysctl: name=net.ipv4.ip_forward value=1 state=present reload=yes + sysctl: name=net.ipv4.ip_forward value=1 + state=present reload=yes - name: deactivate ipv4 rp filter - sysctl: name=net.ipv4.conf.all.rp_filter value=0 state=present reload=yes + sysctl: name=net.ipv4.conf.all.rp_filter value=0 + state=present reload=yes - name: deactivate ipv4 default rp filter - sysctl: name=net.ipv4.conf.default.rp_filter value=0 state=present reload=yes + sysctl: name=net.ipv4.conf.default.rp_filter + value=0 state=present reload=yes - name: install neutron network related packages apt: name={{ item }} state=present force=yes @@ -18,11 +21,13 @@ - neutron-dhcp-agent - name: install neutron openvswitch agent - apt: name=neutron-plugin-openvswitch-agent state=present force=yes + apt: name=neutron-plugin-openvswitch-agent + state=present force=yes when: "'openvswitch' in {{ NEUTRON_MECHANISM_DRIVERS }}" - name: config neutron - template: src=neutron-network.conf dest=/etc/neutron/neutron.conf backup=yes + template: src=neutron-network.conf + dest=/etc/neutron/neutron.conf backup=yes notify: - restart neutron-plugin-openvswitch-agent - restart neutron-l3-agent @@ -31,29 +36,35 @@ - restart neutron-metadata-agent - name: config l3 agent - template: src=l3_agent.ini dest=/etc/neutron/l3_agent.ini backup=yes + template: src=l3_agent.ini dest=/etc/neutron/l3_agent.ini + backup=yes notify: - restart neutron-l3-agent - name: config dhcp agent - template: src=dhcp_agent.ini dest=/etc/neutron/dhcp_agent.ini backup=yes + template: src=dhcp_agent.ini dest=/etc/neutron/dhcp_agent.ini + backup=yes notify: - kill dnsmasq - restart neutron-dhcp-agent - name: update dnsmasq-neutron.conf - template: src=dnsmasq-neutron.conf dest=/etc/neutron/dnsmasq-neutron.conf + template: src=dnsmasq-neutron.conf + dest=/etc/neutron/dnsmasq-neutron.conf notify: - kill dnsmasq - restart neutron-dhcp-agent - name: config metadata agent - template: src=metadata_agent.ini dest=/etc/neutron/metadata_agent.ini backup=yes + template: src=metadata_agent.ini + dest=/etc/neutron/metadata_agent.ini backup=yes notify: - restart neutron-metadata-agent - name: config ml2 plugin - template: src=ml2_conf.ini dest=/etc/neutron/plugins/ml2/ml2_conf.ini backup=yes + template: src=ml2_conf.ini + dest=/etc/neutron/plugins/ml2/ml2_conf.ini + backup=yes notify: - restart neutron-plugin-openvswitch-agent @@ -67,7 +78,8 @@ when: "'openvswitch' in {{ NEUTRON_MECHANISM_DRIVERS }}" - name: assign a port to br-ex for physical ext interface - openvswitch_port: bridge=br-ex port={{ INTERFACE_NAME }} state=present + openvswitch_port: bridge=br-ex port={{ INTERFACE_NAME }} + state=present when: "'openvswitch' in {{ NEUTRON_MECHANISM_DRIVERS }}" - include: igmp-router.yml