1 00:00:07,044 --> 00:00:09,620 - What do we do to create a readers based fact cache? 2 00:00:09,620 --> 00:00:13,243 Well, let's start with a new project directory. 3 00:00:20,420 --> 00:00:23,400 And ensure that we have an ansible.cfg 4 00:00:23,400 --> 00:00:25,763 and an inventory in there. 5 00:00:43,530 --> 00:00:46,690 The major changes in the ansible.cfg 6 00:00:46,690 --> 00:00:49,430 because in ansible.fg we need to indicate 7 00:00:49,430 --> 00:00:52,750 that a redis based fact cache needs to be used. 8 00:00:52,750 --> 00:00:56,290 This is a property of the default section. 9 00:00:56,290 --> 00:00:59,800 So let's say fact_caching to redis fact_caching timeout 10 00:01:08,530 --> 00:01:12,350 to 7,200 or whatever value works for you. 11 00:01:12,350 --> 00:01:16,650 And most important, the fact_caching connection 12 00:01:17,950 --> 00:01:22,950 is localhost 6379:0. 13 00:01:25,060 --> 00:01:29,530 Then we also need to make sure that we have a redis process. 14 00:01:29,530 --> 00:01:34,530 So sudo dnf install -y redis 15 00:01:34,830 --> 00:01:36,540 which shouldn't be necessary in this case 16 00:01:36,540 --> 00:01:38,053 because of the previous demo. 17 00:01:38,920 --> 00:01:43,920 So we can use sudo systemctl status 18 00:01:45,450 --> 00:01:48,810 on redis to verify the operation. 19 00:01:48,810 --> 00:01:53,457 It is running, and let's not forget sudo pip3 20 00:01:53,457 --> 00:01:58,053 and install redis for the corresponding patent components. 21 00:01:59,130 --> 00:02:01,830 Already installed, that makes sense. 22 00:02:01,830 --> 00:02:03,880 And now we can start using it. 23 00:02:03,880 --> 00:02:05,050 So how do we do that? 24 00:02:05,050 --> 00:02:10,050 Oh, ansible all -m setup, right, together some cache. 25 00:02:13,500 --> 00:02:15,900 No, we need sudo password. 26 00:02:15,900 --> 00:02:19,610 So let's enter a sudo password, there we go. 27 00:02:19,610 --> 00:02:21,700 All right, now we have gathered some cache 28 00:02:21,700 --> 00:02:26,700 and let's do some playbook that is using the cache. 29 00:02:28,190 --> 00:02:32,103 So cache check yaml. 30 00:02:41,380 --> 00:02:44,203 Gather_facts will be set to no. 31 00:02:50,480 --> 00:02:54,923 And let's just use the setup module. 32 00:03:03,985 --> 00:03:07,620 And that should do, so, there we go, 33 00:03:07,620 --> 00:03:09,967 ansible.playbook cachecheck -k 34 00:03:13,760 --> 00:03:15,903 because of the configuration. 35 00:03:19,270 --> 00:03:21,800 And there we go, it's gathering the facts. 36 00:03:21,800 --> 00:03:22,730 We don't see anything. 37 00:03:22,730 --> 00:03:23,810 If you want to see something, 38 00:03:23,810 --> 00:03:27,400 use register to show the value of the registered variable. 39 00:03:27,400 --> 00:03:29,610 But the fact, the digital complaining means 40 00:03:29,610 --> 00:03:32,970 that it is totally happy fetching this information 41 00:03:32,970 --> 00:03:34,770 from the fact cache, and that's all.