RHCE習題( 五 )


解答:[student@workstation ansible]$ wget http://content.example.com/user_list.yml[student@workstation ansible]$ vim users.yml---- name: create developer userhosts: dev, testvars_files:- /home/student/ansible/locker.yml- /home/student/ansible/user_list.ymltasks:- name: create group studentgroup:name: studentstate: present- name: create user in developeruser:name: "{{ item.name }}"groups: studentpassword: "{{ pw_developer | password_hash('sha512') }}"state: presentloop: "{{ users }}"when: item.job == "developer"- name: chageshell:cmd: chage -M 30 {{ item.name }}loop: "{{ users }}"when: item.job == "developer"- name: create manager userhosts: prodvars_files:- /home/student/ansible/locker.yml- /home/student/ansible/user_list.ymltasks:- name: create group opsmgrgroup:name: opsmgrstate: present- name: create user in manageruser:name: "{{ item.name }}"groups: opsmgrpassword: "{{ pw_manager | password_hash('sha512') }}"state: presentloop: "{{ users }}"when: item.job == "manager"- name: chage1shell:cmd: chage -M 30 {{ item.name }}loop: "{{ users }}"when: item.job == "manager"[student@workstation ansible]$ ansible-playbook users.yml --vault-id secret.txt 15、更新Ansible庫的密鑰按照下方所述 , 更新現有 Ansible 庫的密鑰:從 http://content.example.com/salaries.yml 下載 Ansible 庫到 /home/student/ansible當前的庫密碼為 AAAAAAAAA新的庫密碼為 bbe2de98389b庫使用新密碼保持加密狀態
解答:[student@workstation ansible]$ wget http://172.25.250.250/ansible2.8/salaries.yml[student@workstation ansible]$ ansible-vault rekey salaries.yml輸入舊密碼輸入新密碼確認新密碼16、創建?個名為 /home/greg/ansible/cron.yml 的 playbook,配置 cron 作業,該作業每隔 2 分鐘運?并執?以下命令:logger "EX294 in progress",以?戶 natasha 身份運?
解答:[student@workstation ansible]$ vim cron.yml---- name: create cronhosts: alltasks:- name: createuseruser:name: natashastate: present- name: create cron for allcron:name: cyminute: '*/2'job: logger "EX294 in progress"user: natasha[student@workstation ansible]$ ansible-playbook cron.yml

推薦閱讀