X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=roles%2Fsriovdp_config%2Ftasks%2Fmain.yaml;fp=roles%2Fsriovdp_config%2Ftasks%2Fmain.yaml;h=3440c825c066b91d0e60bdd995b032d8bab1bfcc;hb=74a49ba6ef2ea715fa492db0bcd85c30398688e8;hp=0000000000000000000000000000000000000000;hpb=a936af362724cca0c5dc2c424902d398f9833410;p=ta%2Finfra-ansible.git diff --git a/roles/sriovdp_config/tasks/main.yaml b/roles/sriovdp_config/tasks/main.yaml new file mode 100644 index 0000000..3440c82 --- /dev/null +++ b/roles/sriovdp_config/tasks/main.yaml @@ -0,0 +1,54 @@ +--- + +# Copyright 2019 Nokia + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: collect network device PCI addresses + shell: dpdk-devbind --status-dev net | grep "^0000.*if=en" + register: devbind + +- set_fact: + pci: [] + iface: [] + +- set_fact: + pci: "{{ pci }} + {{ [ item.split()[0][5:12] ] }}" + iface: "{{ iface }} + {{ [ item.split(' if=')[1].split()[0] ] }}" + with_items: "{{ devbind.stdout_lines }}" + +- set_fact: + ifacepcimap: "{{ dict( iface | zip(pci) ) }}" + +- debug: var=ifacepcimap + +- name: "create {{ sriovdp_config_path }} directory" + file: + path: "{{ sriovdp_config_path }}" + mode: "0700" + state: directory + +- name: "create {{ sriovdp_config_path }}config.yaml" + template: + src: sriovdp_config.yaml.j2 + dest: "{{ sriovdp_config_path }}config.yaml" + +- name: "convert {{ sriovdp_config_path }}config.yaml to config.json" + shell: "python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' <{{ sriovdp_config_path }}config.yaml >{{ sriovdp_config_path }}config.json" + +- name: limit file permissions to root user + file: + path: "{{ item }}" + state: file + mode: "0600" + with_fileglob: "{{ sriovdp_config_path }}*"